Scala 2.7 tried to add functionality to Java []
arrays, and ran into corner cases that were problematic. Scala 2.8 has declared that Array[T]
is T[]
, but it provides wrappers and equivalents.
Try the following in 2.8 (edit/note: as of RC3, GenericArray
is ArraySeq
–thanks to retronym for pointing this out):
import scala.collection.mutable.{GenericArray=>GArray, WrappedArray=>WArray}
scala> GArray(0,1,2) == GArray(0,1,2)
res0: Boolean = true
scala> (Array(0,1,2):WArray[Int]) == (Array(0,1,2):WArray[Int])
res1: Boolean = true
GenericArray
acts just like Array
, except with all the Scala collections goodies added in. WrappedArray
wraps Java []
array; above, I’ve cast a plain array to it (easier than calling the implicit conversion function) and then compared the wrapped arrays. These wrappers, though backed by a []
array, also give you all the collection goodies.