I have some code like the following:
class Test(var f1 : String) {
def this(a : Int) {
this(makeStr(a))
}
private def makeStr(a : Int): Unit = {
"ABC" + a
}
}
The error I get is: not found: value makeStr
.
It seems like the scala compiler cannot see the makeStr
method in the constructor. It seems to be quite different from Java where it is doable. Does anyone know what is the right way to initialize the instance fields which requires some methods to compute the values?