-
-
Save PatilShreyas/de474d4a9a29cb3eaac600eed9f9ca12 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Outer { | |
val value = 10 | |
class Inner1 { | |
fun accessOuter() = println("Outer value = $value") // ❌ Can't access value of Outer class. | |
} | |
inner class Inner2 { | |
fun accessOuter() = println("Outer value = $value") // ✅ Can access value of Outer class. | |
} | |
} | |
fun main() { | |
Outer.Inner1().accessOuter() // #1 | |
Outer().Inner2().accessOuter() // #2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment