티스토리 뷰
this@MainActivity
context를 가져오는 this.
@MainActivity를 작성함으로써 다른 영역에서 MainActivity의 context를 가져온다.
class MainActivity {
fun onCreate() {
val list = listOf(1, 2, 3)
with (list) {
println(this) // >>> [1, 2, 3]
println(this@MainActivity) // >>> MainActivity@2a84aee7
}
}
}
'Android > KOTLIN' 카테고리의 다른 글
Literal (리터럴) (0) | 2022.02.28 |
---|