The power and expressiveness of Swift ranges

Ranges in swift are super simple to create. Yet they come in various forms. let r1 = 1...3 let r2 = 1..<3 let r3 = ...3 let r4 = 3... let r5 = ..<3 They all have range like characteristics, but have slightly different traits. It’s because they’re actually different types. Different Range Types let r1 = 1...3 // ClosedRange<Int> let r2 = 1..<3 // Range<Int> let r3 = ...3 // PartialRangeThrough<Int> let r4 = 3....

March 10, 2023 Β· 7 min