Scala, class using mutable var, update in overriding method

后端 未结 2 402
抹茶落季
抹茶落季 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 08:01

    You can use an early initializer:

    case MyClass(...) extends {
      var mutableArray: ArrayBuffer[Int] = ArrayBuffer.fill(5)(0)
    } with SomeClass(..) {
    

提交回复
热议问题