iOS ● ○ ○ Swift 6

Kodebits Day 52: Tuple Decomposition

Jul 5 2026
Practice tuples with a short swift challenge.

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]


Further Reading