Function back
Returns the last element of the array.
ref inout(T) back(T)
(
scope return inout(T)[] array
) @property;
The element is returned by reference, so back can be also used to change the last element of array if it is mutable.
Parameters
Name | Description |
---|---|
T | Element type of array. |
array | Built-in array. |
Returns
Last element.
Precondition
array.length > 0
.
Example
string s = "Brecht";
static assert(is(typeof(s .back) == immutable char));
assert(s .back == 't');
wstring w = "Тютчев";
static assert(is(typeof(w .back) == immutable wchar));
assert(w .back == 'в');
dstring d = "Паустовский";
static assert(is(typeof(d .back) == immutable dchar));
assert(d .back == 'й');