I just stumbled over some situation that seemed strange to me. Perhaps I really missed the obvious here - in any case, please help me.
Consider the following Scala repl script:
scala> class X(val s: String) { def run=println("(X): "+s) }
defined class X
scala> class Y(s: String) extends X("MY "+s) { override def run=println("(Y): "+s) }
defined class Y
scala> new Y("fish").run
(Y): fish
In the script, I define class X with the class attribute "val s". Then I define the class Y, which should take one argument of the constructor and pass it to the X that it makes. To show the difference, I modify "s" before passing it to X ("MY" + s).
Finally, I create a new Y and call "run". This displays the "fish" on the console, so obviously the attribute "s" of class "X" was obscured by the new attribute "s" that I created in "Y".
Scala 2.8 2.9.1 .
? , , ? ?
!