I recently asked this question about whether it was possible to parameterize the type of a primitive array in Java. (Basically, I have an array that I want to be either a
double or a
float based on some argument. I'm using arrays of primitives rather than arrays of wrapper classes (
Float) because they're much more memory-and-time efficient, especially when dealing with big vector operations. The answer, it appears, is No, you can't do that in Java.
So, my new question is: Can I do this in Scala? I understand that primitives are kind of more hidden, and only boxed on certain operations... So if it is possible to parameterize my arrays as being of Double or Float, and the compiler does implement them as primitives, how do I tell if they're being unboxed, or otherwise implemented less efficiently than if I were to just go "Find: Double, Replace: Float" in my source code?