x[y..z] (span) operator

The span operator returns the subrange of its left-hand operand indexed by its centre and right-hand operands.

Usage

String[] names = {"foo", "bar", "baz"};
String[] firstAndSecond = names[0..1];
String[] secondAndThird = names[1..2];

Description

Definition

The lhs[from..to] operator is defined as follows:

lhs.span(from,to)

See the language specification for more details.

Polymorphism

The x[y..z] operator is polymorphic. The meaning of lhs[from..to] depends on the Ranged interface.

Type

The result type of the lhs[from..to] operator is the element type of the Ranged lhs.

See also