Note: information on this page refers to Ceylon 1.2, not to the current release.
Expressions
An expression produces a value when evaulated. Complex expressions may be constructed by recursively applying operators to simpler expressions. Only certain expressions can legally be used in expression statements.
Usage
Expressions are built using the following constructs.
Literals
"hello, world"
"Hello ``name``, good ``timeOfDay(now)``!";
'a'
1
3.0
Self and outer references
this
outer
super
// or sometimes
super of Foo
package
Invocation
print("Hello")
"hello world".initial(5)
Entry("one", 1)
print {
val = "Hello";
}
"hello, world".initial {
length = 2;
}
Entry {
item = 1;
key = "one";
}
Iterable and tuple enumeration
{1, 2}
[1, 2]
Operators
x = 1
2 + 2
"hello world"[6..11]
0<=x<10
names.empty || !enabled
References
These are callable references
print
String
These are static references
String.size
String.initial
Model references
These are model references:
`String`
`Sequential<String>`
`max<Integer, Null>`
`true`
`List<Integer>.size`
Declaration references
These are declaration references:
`class String`
`interface Sequential`
`function sum`
`value true`
`value List.size`
`package ceylon.language`
`module ceylon.language`
Description
The Ceylon compiler checks expressions for type safey at compile time.
See also
- Expressions in the Ceylon language specification