tipsy
09/14/2018, 7:40 PMDouble.javaClass // DoubleCompanionObject ?
Double::class.java // java Double ?
Double // kotlin Double ?
and when to use which?Shawn
09/14/2018, 8:17 PMDouble
on its own (not used as a type annotation) will refer to Double’s companion object (of which I don’t think there is one)Double::class
will yield a KClass<Double>
.javaClass
should be used when you need the Java Class<T>
of an instantiated objectDouble::class.java
should be used when you need a reference to the Class<T>
by way of knowing the name of the classtipsy
09/14/2018, 8:55 PM