Return multiple values
This pattern is licensed under the CC0 Public Domain Dedication.
Return multiple values of different types from a function.
foo function on lines 3–6 returns a
representing multiple values of different types.
On line 10, we call this function and store the result. We then get
the first of the returned values with
on line 11.
Alternatively, on line 13 we use a structured binding declaration to declare and initialize variables with the returned values. The types of these variables are deduced automatically.
If the values are closely and logically related, consider composing
them into a
11 December 2017