Skip to content

Instantly share code, notes, and snippets.

@PatilShreyas
Last active January 15, 2021 10:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PatilShreyas/de474d4a9a29cb3eaac600eed9f9ca12 to your computer and use it in GitHub Desktop.
Save PatilShreyas/de474d4a9a29cb3eaac600eed9f9ca12 to your computer and use it in GitHub Desktop.
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