Day #12

There are 5+ ways to write a loop in Swift

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
for i in 13 { } //range

for i in collection { } //over a collection

for i in stride() { } //striding

while () { } //while

repeat { } while () //Same thing, but condition is after body.

//Higher order solutions
.forEach {}
.map {}

Originally published 04/14/2021 https://pittcsc.org/, republished 09/08/2022.

Licensed under CC BY-NC-SA 4.0
Last updated on Apr 14, 2021 00:00 UTC
Built with Hugo
Theme Stack designed by Jimmy