Created
January 11, 2014 02:23
-
-
Save manjuraj/8366202 to your computer and use it in GitHub Desktop.
vals and inheritance
This file contains hidden or 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
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