New implementation

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating resource.

Please try to avoid dependencies to third-party libraries and frameworks.

Other implementations
(last items)
#include<vector>
std::vector<int> items;
auto last = items.crend() != items.crbegin() ? *items.crbegin() : -1;
var x = items[items.Count - 1];
int[42] items;
int x = items[$-1];
import std.range;
int[] items;
auto x = items.back();
x = items.last;
x = List.last(items)
x = lists:last(items),
x := items[len(items)-1]
foo :: [a] -> Maybe a
foo [] = Nothing
foo xs = Just $ last xs

x = foo items
x = last items
var x = items[items.length - 1];
int x = items[items.length - 1];
local x = items[#items]
$x = end($items);
x := items[high(items)];
my $x = $items[-1];
x = items[-1]
x = items[-1]
x = items.last
let x = items.last().unwrap();
let x = items[items.len()-1];
val x = items.takeRight(1)