invoke

Synopsis

$ invoke(&closure, @args, ["message"], [key => value, ...])

Dynamically invokes the specified closure. Allows programatic specification of arguments, key/value pairs, and the message parameter.

Parameters

&closure - the closure to invoke.

@args - an array to use as the argument source to pass to the closure.

"message" - the $0 i.e. message parameter for the closure.

key => value - an option to set against the invoked function.

Returns

The return value of the invocation.

Errors

Examples

sub foo { println("Hello: $name $+ , I got your message $0"); println("The sum of $1 + $2 is: " . ($1 + $2)); } invoke(&foo, @(3, 45), "call mother", parameters => %($name => "Raffi"));

Hello: Raffi, I got your message call mother The sum of 3 + 45 is: 48

See Also