destructuring

Destructuring allows the specification of several values at once, when their value is extracted from a Tuple or Entry.

Usage

// destructure an Entry
value key->item = entry;

[Float, Float, Float] point = [1.0, 1.0, 1.0];
// declare three values extracting the valee of each from the tuple
value [x, y, z] = point;

[Float, Float, Float]? maybePoint = point;
// in conjunction with the exists condition
if (exists [x, y, z] =  maybePoint) {
    // ...
}

[Float+] floats = [0.0, 1.0, 2.0, 3.0];
// destructure with spread
value [first, *rest] = floats;

[Float, Float, [String, Icon]] labelledPoint = ...;
// nested destructure
value [x, y, [name, icon]] = labelledPoint;

Description

Destructuring specification is supported:

It is not supported for types other than Tuple or Entry.

See also