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?
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"): _*)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With