Module 02 ยท Collections โ Lesson 3 of 4 ยท ~6 min
Tuples & sets
Tuples: a fixed little bundle
A tuple is like a list, but frozen in length and (usually) meant to hold a few different things together โ think of a GPS fix as (lat, lng). Once built, you can't append to it or reassign a slot.
fix = (37.77, -122.42) lat, lng = fix # unpacking โ pull both values out in one line
That unpacking trick โ lat, lng = fix โ has no direct one-liner in Swift; the closest is destructuring a tuple in a let (lat, lng) = fix.