I would to make the second constructor argument optional, and use the value of the first argument in that case. Is there any way I can do that ? This code doesn't compile as it can't find realUser
:
class CurrentUser(val realUser:String, val masqueradeUser:String = realUser)
I'm sure I can work around it by writing my own constructor, but I wondered if there were a more concise way. Actually now that I've tried writing my own constructor, it isn't that bad:
class CurrentUser(val realUser:String, val masqueradeUser:String) {
def this(realUser:String) = this(realUser, realUser)
}
If someone can come up with something shorter then great, otherwise I'll post my own answer.