String.opSlice

  1. ByCodeUnit!char opSlice(size_t i, size_t j)
    struct String
    @nogc nothrow pure @trusted
    opSlice
    (
    const size_t i
    ,
    const size_t j
    )
  2. ByCodeUnit!(const char) opSlice(size_t i, size_t j)

Parameters

i size_t

Slice start.

j size_t

Slice end.

Return Value

Type: ByCodeUnit!char

A range that iterates over the string by bytes from index i up to (excluding) index j.

Precondition: i <= j && j <= length.

Examples

auto s = String("Vladimir Soloviev");
auto r = s[9 .. $];

assert(r.front == 'S');
assert(r.back == 'v');

r.popFront();
r.popBack();
assert(r.front == 'o');
assert(r.back == 'e');

r.popFront();
r.popBack();
assert(r.front == 'l');
assert(r.back == 'i');

r.popFront();
r.popBack();
assert(r.front == 'o');
assert(r.back == 'v');

r.popFront();
r.popBack();
assert(r.empty);

Meta