Alex Rivera | Logout

How do I compare two arrays in scala?

Asked 2011-03-22T15:02:06.763
78
val a: Array[Int] = Array(1,2,4,5)
val b: Array[Int] = Array(1,2,4,5)
a==b // false

Is there a pattern-matching way to see if two arrays (or sequences) are equivalent?

Edit
Report

1 Answer

22
  a.corresponds(b){_ == _}

Scaladoc: true if both sequences have the same length and p(x, y) is true for all corresponding elements x of this wrapped array and y of that, otherwise false

answered 2011-03-22T16:40:04.393

Your Answer