I am guessing that, for compatibility reasons, the type of vararg parameters Any*
is Array[Any] - please correct this if I'm wrong. However, this does not explain the following error:
class Api(api_url: String, params: Seq[(String, String)]) {
def this(api_url: String, params: (String, String)*)
= this(api_url, params.seq)
}
This code does not compile, but gives the warning:
double definition: constructor Api:(api_url: String, params: (String, String)*)Api and constructor Api:(api_url: String, params: Seq[(String, String)])Api at line 13 have same type after erasure: (api_url: java.lang.String, params: Seq)Api
So how do I define a constructor taking either varargs or a sequence?