yaugenka
yaugenka

Reputation: 2861

How to reference function property within an inner scope

Is it possible do this kind of assignment in Kotlin somehow?

data class MyData(var v: Int?)

fun myFunction(v: Int) {
    val myData = MyData(null).apply { 
        v = @myFunction.v   //does not work
    }

}

PS: the example is unreal is just for the purpose of demonstrating the idea

Upvotes: 0

Views: 29

Answers (1)

IR42
IR42

Reputation: 9682

this.v = v instead of v = @myFunction.v

Upvotes: 2

Related Questions