Reputation: 161
I am using Swift 2.
I used this code:
while contains(currentCardValues, randomNumber + 1) {
I am getting this error:
"contains" is unavailable: call the contains() method on the sequence
Upvotes: 11
Views: 6767
Reputation: 13283
This is because the contains()
method is defined in a protocol extension of Sequence
.
So you should call it this way:
currentCardValues.contains(randomNumber + 1)
Upvotes: 30
Reputation: 569
Please check this code:
let array = [34, 56, 76, 77, 75]
if array.contains(34) {
print("contains")
}else {
print("Not Contains")
}
Here contains() returns bool value
Upvotes: 4