Stride Operators, (a..<b)/step and (a...b)/step

@soroush and I have already pitched a similar solution for a strided(by:) method here for sequences and collections: https://forums.swift.org/t/pitch-adding-strideable-sequences. Under the proposal, ranges work like this with our current code:

for a in (1 ... 5).striding(by: 2) {
  print(a) // 1, 3, 5
}

for a in (1 ... 5).reversed().striding(by: 2) {
  print(a) // 5, 3, 1
}
1 Like