From the Programming in Scala eBook page 78
args.foreach(arg => println(arg))
If a function literal consists of one statement that takes a single argument, you need not explicitly name and specify the argument. Thus, the following code also works:
args.foreach(println)
Good. Now on page 88, thrill is a list, scala REPL says:
thrill: List[String] = List(WILL, FILL, UNTIL)
thrill.count(s => s.length == 4)
Now, here, inside the parentheses, it is a function literal, and to me it seems that it contains a single statement, i.e., (according to my current understanding of single statement) something in one line (and that without semi-colons) and the argument for this function literal is also one, i.e., 's'
I tried to apply the former approach, to eliminate the 's' in the latter example.
scala> thrill.count(length == 4)
With the response
<console>:12: error: not found: value length
thrill.count(length == 4)
^
What is amiss here?