Hey guys I was curious is there was a super class ...
# announcements
a
Hey guys I was curious is there was a super class that all classes that have a companion object inherit, and thusly can be extended? To enable the use of extension methods such as:
Copy code
inline fun <reified T : Any> T.Companion.extensionMethod = ...
z
There is not.
You could request it in #C0B9K7EP2
a
Ok, thanks!
t
but what's the point? Methods in companion objects are basically what would be
static
in Java. If you have a static method/companion object function that exists in every class, why not just leave out the class and make it a global function? If you need the reified type, you can just provide it in the call like this
Copy code
inline fun <reified T : Any> logger() = LoggerFactory.getLogger(T::class.java)
a
Right, it's ultimately just syntactic sugar.