let
A let
expression allows the declaration of new values to be used in
the following expression.
Usage
String hw = let (x="hello", y="world") x + " " + y;
Description
A let
expression allows you to declare new values to be used in an
expression without having to use statement-level declaration.
the specification expression of each value can use all the previously defined
values, like this:
Integer result = let(x = 1, y = x+2, z=x*y) x^y;
Destructuring
let
supports destructuring:
value r = let([x, y] = point) sqrt(x^2+y^2);
Type
The type of a let
expression is the type of the expression part of the let
.