Skip to content

Instantly share code, notes, and snippets.

@beala
Created June 17, 2016 02:37
Show Gist options
  • Save beala/01f1ccd927d74702d785158c6b7bab61 to your computer and use it in GitHub Desktop.
Save beala/01f1ccd927d74702d785158c6b7bab61 to your computer and use it in GitHub Desktop.
I've been using Scala for years and I have no idea how inheritance works. http://docs.scala-lang.org/tutorials/FAQ/initialization-order.html
class C {
val a: Int = 1
val b: Int = a + 10
}
class B extends C {
override val a: Int = 100
}
println(s"a = ${new B().a}")
println(s"b = ${new B().b}")
// a = 100
// b = 10
// ¯\_(ツ)_/¯
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment