Building on the basics from Chapter 5, this chapter covers Swift's more powerful control flow tools: for-in loops, ranges, the versatile switch statement, and pattern matching -- features that make Swift code both concise and expressive.
For-In Loops
The for-in loop is Swift's primary way to iterate over sequences:
for i in 1...5 {
print(i) // Prints 1, 2, 3, 4, 5
}
Full content for this chapter will be added in a future update. The complete article covers ranges (closed and half-open), for-in with collections, where clauses, switch statements, pattern matching, tuple matching, and labeled statements.
Ship your apps faster
When you're ready to publish your Swift app to the App Store, Simple App Shipper handles metadata, screenshots, TestFlight, and submissions — all in one place.
Try Simple App Shipper