I'm learning Scala and I just faced variadic functions. It's almost all ok on the example below I wrote:
object Sscce {
def main(args: Array[String]) {
printStrings("Hello", "Scala", "here", "I", "am");
}
def printStrings(ss: String*): Unit = {
if (!ss.isEmpty) {
println(ss.head)
printStrings(ss.tail: _*)
}
}
}
I understand that String*
means a variable list of strings and that ss
is mapped to a Seq
type. I also assume that a Seq
cannot passed to a variadic function so in the recursive call of printStrings
something has to be done with ss
.
Question is: what is the exact meaning of : _*
? It seems something like a cast to me (since there's the :
symbol)