-
Notifications
You must be signed in to change notification settings - Fork 22
Closed
Description
In 2.12, a mutable.ArraySeq wraps an Array[AnyRef], which means primitives are boxed in the underlying array.
WrappedArray by default uses unboxed arrays for primitives, but it can also wrap an array of boxed primitives.
scala> import scala.collection.mutable.WrappedArray
import scala.collection.mutable.WrappedArray
scala> val a = WrappedArray.make(Array(1))
a: scala.collection.mutable.WrappedArray[Int] = WrappedArray(1)
scala> a.array.getClass
res0: Class[_ <: Array[Int]] = class [I
scala> val a = WrappedArray.make(Array(1): Array[Any]).asInstanceOf[WrappedArray[Int]]
a: scala.collection.mutable.WrappedArray[Int] = WrappedArray(1)
scala> a.array.getClass
res1: Class[_ <: Array[Int]] = class [Ljava.lang.Object;Can / should we make this easier to do?
Also, can we avoid this problem here:
scala> a.array
java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [IOnce things are settled, update the docs at https://github.com/scala/collection-strawman/wiki/FAQ#new-deprecations
Reactions are currently unavailable