Explicit inheritance from Any in Kotlin - Can and How is it done?

kotlin

Solution

You have to call the constructor explicitly:

class MyClass : Any()

THe constructor of Any has no parameters, thus to call it you simply provide the empty parentheses

Problem

The Kotlin documentation says that All classes in Kotlin have a common superclass Any, that is a default super for a class with no supertypes declared If I try and explicitly inherit from Any: ``` class MyClass : Any { } ``` The compiler gives an error: Kotlin: This type has a constructor, and thus must be initialized here I haven't been able to find the documentation for the Any class. Is it possible to explicitly inherit from Any, and if so, what do you pass it?

Original source