The specification statement is used to define the value of a reference or the implementation of a getter or function.
A specification statement for a reference uses the
= assignment symbol:
T t; t = ... /* some expression of type T */
A specification statement for a getter of function uses the
T f(Float float); f(Float float) => ... /* some expression of type T */
The same syntax may be used within a value or function declaration, but in this case it is not, strictly speaking, a specification statement:
T t = ... /* some expression of type T */
T f(Float float) => ... /* some expression of type T */
=> syntax consistently implies lazy evaluation, and
= implies eager evaluation.
There is, in principle, an ambiguity between the assignment operator
= operator) and the specification statement (the
The specification says that the ambiguity is always resolved in favour of
interpreting the statement as a specification statement. In practice, the
only real semantic difference between these constructs is how they affect
definite specifiction analysis.
The Ceylon typechecker ensures that references are definitely specified before they are used. Unlike in Java, references are never automatically initialized to zero or the null value.
These checks can be disabled using the
When extracting values from a
Entry you can use
// declares values x and y, where location is a tuple value [x, y] = object.location;