As you may see that
this@MainActivity or MainActivity@this
is valid while starting activity in kotlin. I tried to find out answer but I did not found anything. Can anyone know about exact difference of it and which one valid ? Why it allowed both ?
As you may see that
this@MainActivity or MainActivity@this
is valid while starting activity in kotlin. I tried to find out answer but I did not found anything. Can anyone know about exact difference of it and which one valid ? Why it allowed both ?
According to Kotlin's Grammar documentation,
MainActivity@this is just a label for this with the name "MainActivity". You can set whatever label you want.
this@MainActivity is an actual reference of this from MainActivity
Hope I make it clear.
this@MainActivity - it is a reference to current MainActivity instance.
MainActivity@this - it is definition of a name of the label, i.e. MainActivity.