Aladdin - Scala Bugtracking
[#1198] project: documentation priority: low category: bug
submitter assigned to status date submitted
Nikolay Martin fixed 2007-07-04 15:52:33.0
subject [contrib #671] ScalaByExample anonymous function syntax
code
Scala by Example
Draft per June 13 2007

Outdated explanation of anonymous functions on chapter 5.1 (page 28) - parameters of typed parameters seem to always require parenthesis around them.

Reading through the explanation, it seems that previously it was possible
to omit the parentheses from the parameter definition in the case of
single parameter ("If there are several parameters, we need to enclose
them in parentheses.").

An anonymous function with single parameter that relies on type inference
seems to work as shown in the next page.



what happened
--- clip ---
scala> def sumSquares(a: Int, b: Int): Int = sum(x: Int => x * x, a, b)
:1: error: ')' expected but identifier found.
def sumSquares(a: Int, b: Int): Int = sum(x: Int => x * x, a, b)
--- clip ---

what expected According to the doc, the definition of sumSquares should be valid. The interpreter, however, gives the error message.
[back to overview]
Changes of this bug report
Nikolay  edited on  2007-07-04 15:52:51.0
Martin  edited on  2007-07-04 16:55:55.0