Ran into some very strange behavior. Why does it matter when I call
::class
?
Copy code
val c1 = Int::class.java to 42::class.java
c1.first to c1.second // (int, int)
val c2 = Int::class.java to 42
c2.first to c2.second::class.java // (int, class java.lang.Integer)
poohbar
08/12/2022, 3:18 PM
and is there any way for me to make the boxed class object (
class java.lang.Integer
) from the primitive class object (
int
)?
j
Joffrey
08/12/2022, 3:20 PM
Kotlin doesn't make a difference between primitive JVM types and their boxed variant in the language itself, but they still exist under the cover. If you're calling
::class
on a value that was previously boxed (when being stored in a generic
Pair
object), it's not the same as calling it on an unboxed literal