it's possible to reference the constructor of some...
# getting-started
y
it's possible to reference the constructor of some class
MyClass
with the path
::MyClass
. for example,
someNullableVal?.let(::MyClass)
. just wondering - is there a fully qualified syntax here? I would expect something like
MyClass::MyClass
or
MyClass::constructor
or something.
🚫 2
e
::MyClass
is the full form, because
MyClass()
is the callable in Kotlin, not
MyClass.MyClass()
or anything like that
y
thank you. looking at this again, I guess that kind of makes sense? a class constructor is a global-scope free function which returns a new instance of the class. and this global scope would make it a root-level function.