Array.length

Expands/shrinks the array.

  1. size_t length [@property getter]
  2. size_t length [@property setter]
    struct Array(T)
    @property @trusted
    void
    length
    (
    size_t len
    )

Parameters

len size_t

New length.

Examples

Array!int v;

v.length = 5;
assert(v.length == 5);
assert(v.capacity == 5);

v.length = 7;
assert(v.length == 7);
assert(v.capacity == 7);

assert(v[$ - 1] == 0);
v[$ - 1] = 3;
assert(v[$ - 1] == 3);

v.length = 0;
assert(v.length == 0);
assert(v.capacity == 7);

Meta