Hi. I want to refer to a method in a companion obj...
# announcements
g
Hi. I want to refer to a method in a companion object and something like
TheClass.Companion::method
works, but is there an alternative that doesn't involve using
.Companion
? Something like
TheClass::method
would've been great but it only works with instance methods. I'm using Kotlin 1.4 in case that's relevant.
g
Is that from java?
g
No, Kotlin
s
The short-cut
TheClass
for
TheClass.Companion
only works if the short-cut is a value, an instance, eg
val c = TheClass
or
TheClass.something()
. In any other case, you can’t use the short-cut and you need to use the full
TheClass.Companion
identifier.
g
I see. Thanks Anton!