8.16.0.2
3.7 Multiple Values🔗ℹ
Returns the vs as multiple result values.
If only one v is provided, the result is the same as just
v. Any other number of values must be received by a context
that is expecting multiple values, such as with a
values binding pattern.
The
values binding operator can only be used in
places where it’s specifically recognized, normally to match multiple
result values. For example, the
lhs_bind position of
def recognizes
values.
The
values annotation can only be used in places
where it’s specifically recognized, normally to annotate multiple
result values. For example, the
maybe_res_annot position of
fun recognizes
values.
|
> def (x, y) = two_numbers() |
|
|
3 |
A
reducer used with
for, expects as many results from a
for body as
ids. When
id is
_, a fresh identifier is used, otherwise
id is bound as follows. For the first iteration of
the
for body, each
id’s value is the result
of the corresponding
init. The results of a
for body
for one iteration then serve as the values of the
ids
for the next iteration. The values of the whole
for expression
are the final values of the
ids.
Calls producer with no arguments, and then calls
consumer with the result value(s) from producer.
Use call_with_values to dispatch on the number of values that
are produced by an expression. The match form cannot make that
distinction, because it always expects a single result value from its
initial subexpression.
|
nothing |
|
apple |
|
apple and banana |
|
apple and 3 bananas |