Your test method is first called in the main constructor. There is no other way that another constructor can avoid calling it before running its own code.
In your case, you should simply undo which constructor does something. The main constructor has a string parameter, and an auxiliary parameter for it. Added gain, you can declare var directly in the parameter list.
class Constructor(var s: String) { def this() = this(null) def testMethod() = println(s) testMethod() }
In general, the main constructor should be more flexible, usually assigning each field from a parameter. Scala syntax makes that very easy. You can make this main constructor private if required.
Edit : even easier with default setting
class Constructor(var s: String = null) { def testMethod = println(s) testMethod }
Didier dupont
source share