Scala, class using mutable var, update in overriding method

后端 未结 2 404
抹茶落季
抹茶落季 2021-01-28 07:38

I am having a hard time understanding how to get the following code structure to work.

In Scala I have a class MyClass which inherits from SomeClass<

2条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-28 07:48

    Probably you are hitting the infamous "one question FAQ" about initialization order.

    If the method is invoked by the superclass constructor, then your initialization happens after that, resetting the data to zero.

提交回复
热议问题