Names an intermediate value inside the expression that consumes it, so a computation stays a single expression
instead of splitting into a temporary variable and a statement, and the name is free to shadow the one the value was
computed from, putting the raw value out of reach for the rest of the mapper.
The mapper is always called and its result reported unchanged, whatever the value: an undefined value is handed on
like any other, so reach for opt where it is to bypass the mapper instead.
The value computed from value by mapper; errors raised by mapper propagate to the caller unchanged
Example
functionlabel(...tags: string[]): string { // the raw tags are unreachable past the mapper returnmap(tags.filter(tag=>tag !== ""), tags=>tags.length === 0 ? "untagged" : tags.join(", ")); }
Applies a mapper to a value.
Names an intermediate value inside the expression that consumes it, so a computation stays a single expression instead of splitting into a temporary variable and a statement, and the name is free to shadow the one the value was computed from, putting the raw value out of reach for the rest of the mapper.
The mapper is always called and its result reported unchanged, whatever the value: an undefined value is handed on like any other, so reach for opt where it is to bypass the mapper instead.