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
-
x[y...](upper span) operator used for obtaining a tail of aRanged. - API documentation for
Ranged - sequence operators in the language specification
- operator precedence in the language specification
- Operator polymorphism in the Tour of Ceylon