def echo(args: String*) = for (arg <- args) println(arg)
'... Thus, the type of args inside the echo function, which is declared as type "String*" is actually Array[String]'
I would mention in a footnote, that a syntax of passing variable length argument list in Scala closely resembles one in C/C++. I'm pretty sure Martin chose asterisk, because it is used in C/C++, although in C/C++ it denotes a pointer to a first element of array. Another difference is that in C/C++ we would pass an array to such a function, not several arguments, separated by comma. There is definitely a feel, that C++ is more functional language than Java, for example a name of a function is a pointer (reference) variable pointing to a function itself, which allows to pass a function to another function as parameter and return as return value. First-class functions, isn't it? So, Scala feels partly as a consistent attempt to re-introduce to Java functional features which were dropped when Java creators used C++ to produce new [over?]simplified language.
Personally, I always loved when authors of books described new languages in comparison to existing ones, like Trey Nash is doing in his "Accelerated C# 2008", comparing C# to C++, like David Flanagan is doing in "JavaScript. The Definite Guide", comparing JavaScript to C/C++, and like Bruce Eckel is doing in "Thinking in Java", comparing it to... C++ again. (By the way, Bruce is considering Scala as a next "big" language, which will gradually and partially replace Java the same way Java did to C++.) One fresh and excellent example is "Real World Functional programming in .NET" by Tomas Petricek http://www.manning.com/petricek. This book introduces F# language (a merge of OCaml and .NET platform) and functional concepts in constant comparison to limited functional features of C# 3.0. It helps a lot to understand both F# and functional features of C#. It even helps to understand Scala, because functional concepts are the same in both F# and Scala. To learn programming languages in comparison is not an easy task. But it is, in my opinion, a most powerful way to obtain real understanding of languages. Footnotes or special text blocks, describing similarities and diffrence between Scala and Java, Scala and Haskell, Scala and F# - makes a Scala book shines even more.
I've just posted a bit more philosophical thoughts about Scala approach vs. F# approach in introducing functional ideas to OOP world, about their simplicity/difficulty and chances for success. No, I don't feel like I'm a guru. I just feel it is extremely interesting and important to understand how each language fits into a common picture.
Not sure if this is the best place to post this, but it *is* about variable arguments ;-)
On p154 of version 5 (section 8.8), it is stated that "the type of args inside the echo function [def echo(args: String*) ...] is actually Array[String]".
According to the Scala language definition, should it not actually be Seq[String]? Cf. section 4.6.2 Repeated Parameters of the Scala Reference and
"I would mention in a footnote, that a syntax of passing variable length argument list in Scala closely resembles one in C/C++. I'm pretty sure Martin chose asterisk, because it is used in C/C++, although in C/C++ it denotes a pointer to a first element of array."
I would bet that it's because * is Kleene repetition (familiar from regular expressions) and that it has nothing to do with C or C++.