score:5

Accepted answer
gplayer(1, 42, 1, 9)

is the same as writing

gplayer.apply(1, 42, 1, 9)

so instead of defining an alternative constructor, you should define an alternative apply method in the companion object gplayer.

case class gplayer(id: long, glimpleid: long, layerorder: int, created: long, attachments: list[gpattachment]) 

object gplayer {
  def apply(id: long, glimpleid: long, layerorder: int, created: long) = gplayer(id, glimpleid, layerorder, created, list[gpattachment]())
}

if you want to call the altnernative constructor instead, you must add the new-keyword:

new gplayer(1, 42, 1, 9)

edit: as nicolas cailloux mentioned, your alternative constructor is really just providing a default value for the member attachments, so the best solution would actually be to not introduce a new method, but to specify this default value as follows:

case class gplayer(id: long, glimpleid: long, layerorder: int, created: long, attachments: list[gpattachment] = nil)

score:2

note that in your case, you could just provide a default value for the last argument :

case class gplayer(id: long, glimpleid: long, layerorder: int, created: long, attachments: list[gpattachment] = list())

Related Query

More Query from same tag