Pattern: Use of first(where:) != nil
Issue: -
Prefer contains
over first(where:) != nil
.
Examples of correct code:
let first = myList.first(where: { $0 % 2 == 0 })
let first = myList.first { $0 % 2 == 0 }
Examples of incorrect code:
↓myList.first { $0 % 2 == 0 } != nil
↓myList.first(where: { $0 % 2 == 0 }) != nil
↓myList.map { $0 + 1 }.first(where: { $0 % 2 == 0 }) != nil
↓myList.first(where: someFunction) != nil
↓myList.map { $0 + 1 }.first { $0 % 2 == 0 } != nil