Reference nested class-constructor

What is the way to reference a nested classes constructor-param:

class SomeClass {
    class State(val value: String)
}

class OtherClass{
    class State(val value: String)
}


fun t() {
    //doesn't work
    "".let(::SomeClass.State) 
    "".let(::OtherClass.State)
}

importing State from both of the classes under a different alias and calling without the outerclasses does work, but I was hoping there is a way to do this while the outerclass in the reference…

I think what you are looking for is SomeClass::State, but this would still fail in your example

"".let(SomeClass::State)

Type mismatch: inferred type is KFunction0<SomeClass.State> expected (String) → ???

1 Like

Thx!
I knew you could access functions on the class that way.
I didn’t know Kotlin would also make it refer to the constructor of the nested class.
Updated the answer to make the example work.

Thx again!