The book lists the following earlier in the text:
In order for the declaration to compile in a playground, you need to provide an initial definition like so:
var multiplyClosure = { (a: Int, b: Int) -> Int in
return a * b
}
Just after that, it completely omits the let kyword, for reasons that I do not understand (is it okay to omit the let keyword in that way?):
...if the closure consists of a single return statement, you can leave out the return keyword, like so:
multiplyClosure = { (a: Int, b: Int) -> Int in
a * b
}
Immediately after that text, it states the following:
Next, you can use Swift’s type inference to shorten the syntax even more by removing the type information:
multiplyClosure = { (a, b) in
a * b
}
Note that in this code as well, the let keyword is completely omitted again. I don't understand why or if that's normal practice.
Finally, it states the following, (which is the text/code I initially typed in my original post):
And finally, you can even omit the parameter list if you want. Swift lets you refer to each parameter by number, starting at zero, like so:
multiplyClosure = {
$0 * $1
}
This comprises all of/the only code that precedes the code listed in my original post.