Reputation: 5495
The code in question is a bit that comes from this answer, and checks whether a given index is available or not.
Specifically, only in XCode 8.3 does the following issue who up (the code compiles fine in XCode 9 beta. This code is also decidedly Swift 3, and not 4).
I looked into issues relating to the "missing argument" error, and the typical response is to make sure to include the optional argument. However, in here all 3 are included optional
i
, which is the type Index
.
What am I doing incorrectly with the syntax here?
Upvotes: 0
Views: 77
Reputation: 1443
The syntax was changed to this:
public func contains(where predicate: (Element) throws -> Bool) rethrows -> Bool
Now you should use this one
self.indices.contains(where: { (object) -> Bool in
//make comparison here
})
Or
self.indices.contains(where: {$0 == "equal to something"})
Or you can use something like this:
if self.indices.first(where: {$0 == "equal something"}) != nil {
return self[i]
}else{
return nil
}
BTW, Sets are still have a bool value returned after calling "contains". Check this
Upvotes: 1