New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prefer `contains` over `first(where:) != nil` #1514

Closed
jpsim opened this Issue May 15, 2017 · 1 comment

Comments

Projects
None yet
3 participants
@jpsim
Collaborator

jpsim commented May 15, 2017

See 61e9b39

@jpsim jpsim added the rule-request label May 15, 2017

@masters3d

This comment has been minimized.

Show comment
Hide comment
@masters3d

masters3d May 18, 2017

Contributor

Here are some variations

let someArray = [1,2,3,3,4,4,5,56,6,7,8]
let myFunc = { (myInt:Int) in return myInt == 56 }

print(someArray.first(where: { $0 == 56 }) != nil)
print(someArray.first(where: myFunc ) != nil)
print(someArray.first{ $0 == 56 } != nil)
Contributor

masters3d commented May 18, 2017

Here are some variations

let someArray = [1,2,3,3,4,4,5,56,6,7,8]
let myFunc = { (myInt:Int) in return myInt == 56 }

print(someArray.first(where: { $0 == 56 }) != nil)
print(someArray.first(where: myFunc ) != nil)
print(someArray.first{ $0 == 56 } != nil)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment