While you may take advantage of closures being method handles and call them using
invokeWithArguments
, there is a (much) better way.
When you have a reference to a closure, you may simply call it as a regular function. The previous
adder
example can be equivalently rewritten as:
let adder = |a, b| -> a + b println(adder(1, 2)) let addToTen = adder: bindTo(10) println(addToTen(2))