for-loop vs filter()

Here’s the code if you want to experiment with it!

import Foundation

let integers = [1, 2, 3, 4, 5]

let evensOnly = integers.filter { $0.isMultiple(of: 2) }
Previous
Previous

as? vs is

Next
Next

Closures and Capture Lists