Is it possible to combine variable arguments and default parameters in a Scala method function definition? Specifically, I'm trying to write a patch method with the following signature:
def patch(body: String, contentType: ContentType = ContentType.APPLICATION_JSON, customHeaders: (String, String)*)
I get the error Parameter section with *-parameter cannot have default arguments
. So I assume it was a matter of ordering the parameters. However, I'm required to place *-parameters last.
My questions are:
Why does *-parameter have to be last? Is it so the compiler can easily parse the arguments?
Why can't *-parameter come after the default arguments? I imagine the same argument applies where it's easier for the compiler to parse arguments because default arguments and variable arguments are both optional.