I'm working on a chapter on closures from a book and in it they mention the following:
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
}”
I decided to try that myself and typed the following in Swift:
let thisEquals = {
$0 * $1
}
thisEquals(10, 4)
However, upon doing so, I get the following error message:
Playground execution failed:
error: Deletable Playground 4.playground:2:8: error: ambiguous use of operator '+'
$0 + $1
^
Could someone please explain to me why this is happening? Is there something that I'm doing wrong here? What is meant by "ambiguous use" here and why isn't this code working? Please help. Thank you.