Function String.opSlice

ByCodeUnit!(char) opSlice (
  const(ulong) i,
  const(ulong) j
) pure nothrow @nogc @trusted;

ByCodeUnit!(const(char)) opSlice (
  const(ulong) i,
  const(ulong) j
) pure nothrow @nogc @trusted const;

Parameters

NameDescription
i Slice start.
j Slice end.

Returns

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

Precondition

i <= j && j <= length.

Example

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);