0
 class A{
    ..........
    var name:String? // Member variable
    fun doSomeThing(name:String?)//name as function variable
    {
       uiScope.launch{name=name}
    }
    ..........
   }

In case of java we use this.name=name, but how to do it in kotlin

PraveenK
  • 51
  • 1
  • 4

1 Answers1

2

Figured out the same in kotline as follows

class A{
..........
var name:String? // Member variable
fun doSomeThing(name:String?)//name as function variable
{
   uiScope.launch{this@A.name=name}
}
..........

}

PraveenK
  • 51
  • 1
  • 4
  • `this@A` instead of `this` should only be needed inside an inner class, where Java would have [`A.this`](https://stackoverflow.com/questions/11276994/what-does-qualified-this-construct-mean-in-java) – Alexey Romanov Jan 30 '21 at 09:01
  • 1
    @AlexeyRomanov I guess inside `CoroutineScope#launch` you get a receiver to a child `CoroutineScope`, so qualified access is required. – Animesh Sahu Jan 30 '21 at 14:19
  • @AnimeshSahu That makes sense, didn't think of it! – Alexey Romanov Jan 31 '21 at 10:21