Not. If you try, the compiler will tell you:
error: parameter section with parameter `* 'has no default arguments
But you can achieve the same result when overloading the method:
class A { def foo(args: String*): Unit = args.foreach(println) def foo(): Unit = foo("A", "B", "C") }
Here, when you provide the arguments:
scala> (new A).foo("A", "B") A B
And here is the "default":
scala> (new A).foo() A B C
dhg
source share