Reputation: 489
I have been using :_*
to convert Seq[String]
to String*
and I realized that I do not understand how this works under the hood.
Is there a simple way to think about this?
Upvotes: 6
Views: 147
Reputation: 167891
Under the hood, String*
is passed as a Seq[String]
. It's all just syntactic sugar:
def blah(ss: String*) = {...}
blah("Hi","there")
is turned into
def blah(ss: Seq[String]) = {...}
blah(Seq("Hi", "there"))
and :_*
just means "hold the sugar, I've already got what you need--a Seq!"
Upvotes: 7