scala case class named parameters

Viewed 6770

Is there (or will in the nearest feature) in scala possible to create case class with named parameters? I mean to construct case class object using named parameters in constructor.

My case classes have a lot of fields. It is prone to error having constructors with a lot of not named parameters.

I would like to get (at the moment not working example):

case class X(x0:String, x1:Int, x2:String)
val x = X(x0="Xstring", x1=12, x2="x2String")

As workaround we could provide factory method like below excerpt shows, but this is ugly solution:

case class X(x0:String, x1:Int, x2:String)
object X {
    private nullX = X(null, null, null)
    def createX = nullX.copy _
}

val x = X.createX(x0="Xstring", x1=12, x2="x2String")

Any clues ? :)

EDIT: This was bug in intellij idea scala plugin some old version. Plase don't vote down any more ;)

1 Answers
Related