0

Im trying to figure out how to check if array contains another array:

var grid: [[Int]]!
grid = []
grid.append([1,1])

if grid.contains([1,1]) {

}

but the line

if grid.contains([1,1]) {

throws the error:

Contextual type '@noescape ([Int]) throws -> Bool' cannot be used with array literal

0

1 Answer 1

1

Swift arrays doesn't conform to Equatable by default. But you can still compare them in the predicate:

if (grid.contains { $0 == [1,1] } == true) {

}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.