Skip to content

Instantly share code, notes, and snippets.

@manjuraj
Created January 11, 2014 02:23
Show Gist options
  • Save manjuraj/8366202 to your computer and use it in GitHub Desktop.
Save manjuraj/8366202 to your computer and use it in GitHub Desktop.
vals and inheritance
abstract class Foo {
val a: String
val b = "hello" + a
}
class Bar extends Foo {
val a = "world"
}
// What is wrong with the above code?
// The superclass constructor is invoked before the subclass constructor. As a
// result the value of 'a' is uninitialized (null) when we are initializing
// the value of b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment