iOS ● ○ ○ Swift 6

Kodebits Day 98: Filter Evens

Sep 26 2026
Practice higher-order functions with a short swift challenge.

What is the output?

let nums = [1, 2, 3, 4, 5, 6]
let evens = nums.filter {
  $0.isMultiple(of: 2)
}
print(evens)

[spoiler title="Solution"]

Answer:

[2, 4, 6]

Explanation:

filter returns elements matching the predicate condition.

[/spoiler]


Further Reading