I would make the second argument of the constructor optional and use the value of the first argument in this case. Is there any way to do this? This code does not compile since it cannot find realUser :
class CurrentUser(val realUser:String, val masqueradeUser:String = realUser)
I'm sure I can get around this by writing my own constructor, but I wondered if there was a more concise way. In fact, now that I have tried to write my own constructor, this is not so bad:
class CurrentUser(val realUser:String, val masqueradeUser:String) { def this(realUser:String) = this(realUser, realUser) }
If someone can come up with something shorter than great, otherwise I will send my own answer.
constructor scala
Nick
source share