Expression statements
An expression statement simply evaluates an expression.
Usage
An expression statement is just the expression followed by a semicolon (;
).
foo();
Description
No all expressions can be treated as statements in this way. For example:
"";
is not a legal expression statement. Since no side-effects result from
evaluating a String
literal and then discarding it, the statement is
useless. Only the following expressions may be used as statements:
- assignment or compound assignment,
- prefix or postfix increment or decrement,
- invocation of a method, or
- instantiation of a class.
On execution, the expression's value is discarded.
See also
- The reference on expressions
- Expression statements in the Ceylon language specification