What is the meaning of colon, underscore and star in lift's SiteMap(entries:_*)?
Solution 1:
OK, after my colleague mentioned to me, that he encountered this secret incantation in the Programming in Scala book, I did a search in my copy and found it described in Section 8.8 Repeated parameters. (Though you need to search with space between the colon and underscore :-/ ) There is a one sentence to explain it as:
... append the array argument with a colon and an
_*
symbol, like this:scala> echo(arr: _*)
This notation tells the compiler to pass each element of
arr
as its own argument toecho
, rather than all of it as a single argument.
I find the description offered here more helpful.
So x: _*
is like a type declaration that tells the compiler to treat x
as repeated parameter (aka variable-length argument list — vararg).