A quite simple exercise from Cay Horstmann\'s book « Scala for the impatient » keeps puzzling me. It\'s about primary
,auxiliary
and <
Actually, what I had in mind is a version with a no-argument primary constructor, like this:
class Employee {
private var _name = "John Q. Public"
var salary = 0.0
def this(n: String, s: Double) { this(); _name = n; salary = s; }
def name = _name
}
Clearly, this is inferior to defining the fields in the primary constructor, which is the point that I wanted to make.