lambda

Synopsis

& lambda(&closure, [$key => "value", ...])

Copies &closure into a new closure. The new closure environment is initialized with all of the specified key/value pair arguments.

Parameters

&closure - the closure to copy into a new instance.

$key => value - sets $key in the this scope of the new closure to the right hand side value.!!this -

... - any number of $key => value pairs may be specified.

Returns

A new closure.

Examples

$myfunc = lambda({ println("foo! $x"); $x++; }, $x => 0); [$myfunc]; [$myfunc];

foo! 0 foo! 1

See Also