For an instance of an inner class, this
refers to that inner class instance,
not the instance of the outer class that created it. So, here, we get
class Bar
when we try printing the class name for an instance of Bar
using
this
.
You can learn more about this in:
Tags:
xxxxxxxxxx
1
class Foo {
2
inner class Bar {
3
fun that() = this
4
}
5
}
6
7
fun main() {
8
val foo = Foo()
9
val bar = foo.Bar()
10
11
println(bar.that()::class)
12
}