Scala : Why can't we do super.val?

前端 未结 2 1098
孤街浪徒
孤街浪徒 2021-01-12 22:58

I am practicing this code from JavaTpoint for learning inheritance in Scala. But I cannot access the member Bike from the class Vehicle who\'s value is initialized to zero.

2条回答
  •  清酒与你
    2021-01-12 23:49

    Answers to similar questions here overriding-vals-in-scala, or here cannot-use-super-when-overriding-values say: Scala compiler does not allow to use super on a val

    Why is that? Discussion in last link above points to: SI-899. And the first comment there says following: it was changed so that traits could override vals to be more uniform with classes

提交回复
热议问题