as far understand, scala's == defines natural equality of 2 objects.
i expected array(0,1,2) == array(0,1,2)
compares natural equality. example, checks if elements of array return true when compared corresponding elements of other array.
people told me scala's array
java []
compares identity. wouldn't more meaningful override array
'sequals
method compare natural equality instead?
scala 2.7 tried add functionality java []
arrays, , ran corner cases problematic. scala 2.8 has declared array[t]
t[]
, provides wrappers , equivalents.
try following in 2.8 (edit/note: of rc3, genericarray
arrayseq
--thanks retronym pointing 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 array
, except scala collections goodies added in. wrappedarray
wraps java []
array; above, i've cast plain array (easier calling implicit conversion function) , compared wrapped arrays. these wrappers, though backed []
array, give collection goodies.
Comments
Post a Comment