What does this print?
func minMax(_ a: Int, _ b: Int)
-> (min: Int, max: Int) {
return a < b ? (a, b) : (b, a)
}
let result = minMax(7, 3)
print(result.min)
print(result.max)
Try it in the online Swift Playground →
[spoiler title="Solution"]
Answer:
3 7
Explanation:
Tuples group values; named elements provide clear access.
[/spoiler]