In scala, how can I check if a multidimensional array of Int contains an array, for instance:
val test = Array(Array(1, 2), Array(2, 1))
test.contains(Array(1, 2)) // this results to false
test.contains(test(0)) // this results to true
So it seems scala is comparing the object reference too, in the first case, despite having the same elements, it is a different object, hence returning false. Is this right?
In the second case, I'm testing against one of the same objects already contained in the list, hence returning true.
How can I achieve the expected result, i.e., checking if a multidimensional array in Scala contains a specific array?
I have seen this is possible with tuples, but not with arrays.