Note: information on this page refers to Ceylon 1.1, not to the current release.
is
operator
The non-associating, binary infix is
operator is used to test the type of an
expression.
Usage
void m(Object? obj) {
Boolean isNumber = obj is Number;
Boolean isNull = obj is Null;
}
Description
Definition
The is
operator is primitive.
Note that because Ceylon supports reified generics you may use is
with a
parameterized type, for example you can write
Boolean intList = obj is List<Integer>;
Polymorphism
The is
operator is not polymorphic.
Type
The result type of the is
operator is Boolean
.
Note
Do not to confuse the is
operator described here and which
takes the infix form attribute is Type
with the
is
condition used in if
, assert
and
while
statements and which takes the prefix form
is Type attribute
.
See also
extends
operatorsatisfies
operator- operator precedence in the language specification
if (is ...)
special formcase (is ...)
special form