Use first(where:)

Swift

Use first(where:) to get the first element of the sequence that satisfies the given predicate.
let numbers = [1, 2, 7, 3, 4, 5, 6, 7] let firstSeven = numbers.first { $0 == 7 } // Instead of: // let firstSeven = numbers.filter({ $0 == 7 }).first