In Kotlin, using a scope function such as "with" that allows the this reference inside the block to reference the lambda result, is it possible to reference the outer class member when it has the same name as one of the fields in the result?
eg
data class Person(name: String)
...
class MyClass {
var name = ""
with(personRepository.getPerson(personId)) {
// How do we set the class "name" member - "this.name" or just "name" refers to the scoped object?
name = this.name // ???
}
Obviously using a different variable name is the simple workaround but just wondering if there is a syntax for when the variables have the same name
class MyClass {
var personName = ""
...
with(personRepository.getPerson(personId)) {
personName = this.name
}