Scala local variable inside primary constructor
问题 How in Scala I can define local variable in primary constructor? I need to solve this exercise from Scala for the impatient book: Write a class Person with a primary constructor that accepts a string containing a first name, a space, and a last name, such as new Person("Fred Smith"). Supply read-only properties firstName and lastName. Should the primary constructor parameter be a var, a val, or a plain parameter? Why? And for now my solution looks like this: class Person(firstLast: String) {