is there a docs page explaining the difference bet...
# announcements
t
is there a docs page explaining the difference between
Copy code
Double.javaClass // DoubleCompanionObject ?
Double::class.java // java Double ?
Double // kotlin Double ?
and when to use which?
s
Double
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 object
Double::class.java
should be used when you need a reference to the
Class<T>
by way of knowing the name of the class
I don’t believe there is any one particular docs page that explains the differences unfortunately, this is just what I’ve learned by idling in Slack and checking out stackoverflow questions
t
thanks @Shawn, that's helpful
👍 2