Function front
Returns the first element of the array.
ref inout(T) front(T)
(
scope return inout(T)[] array
) @property;
The element is returned by reference, so front can be also used to change the first element of array if it is mutable.
Parameters
Name | Description |
---|---|
T | Element type of array. |
array | Built-in array. |
Returns
First element.
Precondition
array.length > 0
.
Example
string s = "Wenn die Wunde nicht mehr wehtut, schmerzt die Narbe";
static assert(is(typeof(s .front) == immutable char));
assert(s .front == 'W');
wstring w = "Волны несутся, гремя и сверкая";
static assert(is(typeof(w .front) == immutable wchar));
assert(w .front == 'В');
dstring d = "Для писателя память - это почти все";
static assert(is(typeof(d .front) == immutable dchar));
assert(d .front == 'Д');