In Scala (2.7), if I have this function:
def foo(args: Array[String]) =
for (arg <- args) println(arg)
If I now try to define the following:
def bar(args: String*) = foo(args)
then the compiler complains:
<console>:5: error: type mismatch;
found : String*
required: Array[String]
def bar(args: String*) = foo(args)
^
I don't understand this error, since the Programming Scala book states that the type of args
inside function bar
is actually Array[String]
. How am I supposed to write such a wrapper function with repeated arguments?