Reputation: 21062
Consider these methods:
def clearlnOut(coll : Any*)
{
clearOut(coll:_*,"\n") // error
}
def clearOut(coll : Any*)
{
...
The compiler says:
error: no `: _*' annotation allowed here (such annotations are only allowed in arguments to *-parameters)
Now I am puzzled. It is clear case of using variadic arguments, so how to pass such augmented "collection" properly?
Upvotes: 5
Views: 616
Reputation: 340713
Try this:
def clearlnOut(coll : Any*) {
clearOut(coll ++ "\n")
}
UPDATE: much better version suggested by @Rex Kerr (see comment below):
def clearlnOut(coll : Any*) {
clearOut((coll :+ "\n"): _*)
}
Upvotes: 6