We know that scala does not support more than 22 parameters, but if I write this
def echo(args: String*) = for (arg <- args) println(arg)
we can use more than 22 parameters to call this function as follows.
echo("1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1","1")
But I think this is an array. So he can do it, and I tried it
val a = Array[String]("1","2","3");echo(a)
This code should be wrong, so here is my first question, why is this happening? and if I try to write this
echo(a : _*)
Right, the second question: what does this "_ *" sign mean? I cannot use this code in other ways, for example in for (). So echo (a: _ *) is the correct code?