KeyPaths as closures
Here’s the code if you want to experiment with it!
import Foundation
extension Int {
var isEven: Bool { self.isMultiple(of: 2) }
}
let numbers = [1, 2, 3, 4, 5]
let evens = numbers.filter(\.isEven)
Here’s the code if you want to experiment with it!
import Foundation
extension Int {
var isEven: Bool { self.isMultiple(of: 2) }
}
let numbers = [1, 2, 3, 4, 5]
let evens = numbers.filter(\.isEven)