so, I got a `Vec3` class where I retrieve componen...
# announcements
e
so, I got a
Vec3
class where I retrieve components as
Copy code
override var x: Float
        get() = array[ofs]
        set(value) = array.set(ofs, value)
Why from java
getX()
returns
Float
instead
float
?
a
What type is
array
?
Array<Float>
?
p
yeah for primitive floats you would have to use
FloatArray
e
FloatArray
however
Vec3 : Vec3t<Float>
and
Copy code
abstract class Vec3t<T : Number> {

    abstract var x: T
a
then there is no way to use primitive types
d
No way to use them directly. The compiler will use them transparently when possible.
e
how can I check if a simple code like
Copy code
val a = Vec3()
    val b = a.x
is involving boxing?
this is the corresponding bytecode
Copy code
L2
    LINENUMBER 146 L2
    ALOAD 1
    INVOKEVIRTUAL glm_/vec3/Vec3.getX ()Ljava/lang/Float;
    INVOKEVIRTUAL java/lang/Float.floatValue ()F
    FSTORE 2
   L3
@Andreas Sinz @diesieben07
d
You mean you want to be able to tell without looking at the bytecode?
e
either way
d
Well, when looking at the bytecode you can see that
java.lang.Float
is being used, which is the boxed version
e
if I inline
.x
the bytecode viewer crash
how to check if it's boxed then?
d
You could use javap or other bytecode viewers
Or know that generics means erasure, which requires boxing