Today was Day 4 of 100 Days of Swift, which meant loops.

The first new bit for me today was that unlike in Python, you can’t loop over a tuple in Swift. I’m not sure I’ve ever treated a Python tuple as an iterable, but it’s good to know that you can’t do that in Swift.

Another piece of syntax that was new to me was Swift’s repeat loops:

var wins = 1
repeat {
    wins += 1
} while wins <= 3

repeat {
    print("This will run once")
} while false

Finally, while I probably could have guessed that Swift would support loop labels, I wasn’t quite sure what the syntax would be. Again, this isn’t the kind of thing I’ve used very much, but it’s still nice to get a little clarity on the Swift behavior:

outer: for i in 1...4 {
    for j in 1...4 {
        if String(i*j).count > 1 {
            print("We got double digits")
            break outer

After yesterday’s late night, I’m a little behind on work for MFArtist, so I’ll be spending at least 60 minutes today catching up.