I have a scala class:
class Foo {
def this(st: String) {
var baz = List[String]()
var jaz = "one" + st
// more code logic
}
}
First above code does not compile. Secondly I want baz and jaz to be private variables local to the lone constructor above and not instance variables.
How to solve this problem?
It does not compile because the first thing that MUST happen in an auxiliary constructor is a call to the primary constructor. I don’t understand the second question, since the variables you have declared already ARE private