Note: information on this page refers to Ceylon 1.2, not to the current release.
x[y:n]
(measure) operator
The measure operator returns the subrange of its left-hand operand starting from its central operand and including as many elements as given by its right-hand operand.
Usage
String[] names = {"foo", "bar", "baz"};
String[] foo = names[0:1];
String[] barBaz = names[1:2];
String[] empty = names[1:0];
Description
Definition
The lhs[from:length]
operator is defined as follows:
lhs.measure(from,length)
See the language specification for more details.
Polymorphism
The x[y:n]
operator is polymorphic.
The meaning of x[y:n]
depends on the
Ranged
interface.
Type
The result type of the lhs[from:length]
operator is the element type of the Ranged
lhs
.
See also
-
x[y..z]
(span) operator used for obtaining a subrange from aRanged
. - API documentation for
Ranged
- sequence operators in the language specification
- operator precedence in the language specification
- Operator polymorphism in the Tour of Ceylon