Using Java generics
Gosu can directly access types that use Java generics. In typical code, Gosu works identically to Java.
The runtime information about a type that uses generics is different for Java and Gosu generic types. You can access
this information by using the typeof operator:
- The Java compiler erases the parameterization of the type during the compilation to Java byte code. At run time, the
type
ArrayList<Integer>for a Java type appears just asArrayList. This Java behavior is known as type erasure. - If the type is defined in Gosu, the runtime type retains the parameterization of the generic
type. At run time, the type
ArrayList<Integer>for a Gosu type appears asArrayList<Integer>. This Gosu behavior is known as type reification.
See also
