0Pricing
Swift Academy · Lesson

Iteration patterns & mutability

Learn common iteration patterns over arrays/dictionaries/sets, use indices and enumerated(), and understand mutability with let vs var (copy-on-write basics).

Why iteration & mutability?

Goal: Iterate safely and clearly over collections, and know when they are mutable. We'll cover arrays, dictionaries, sets, indices, and enumerated(), plus let vs var.

for-in (Array)

for-in iterates directly over elements; simple and clear for arrays.

let nums = [10, 20, 30]
for n in nums {
    print("value:", n)
}

All lessons in this course

  1. Arrays, Dictionaries & Sets
  2. Sets — membership & operations
  3. Iteration patterns & mutability
← Back to Swift Academy