Core Function MKFunc
From Sputnik Wiki
(Difference between revisions)
(Created page with "<pre> MKFunc ( <params>, <body> ) </pre> === Description === Create a user defined function to be called from a variable. === params=== A string that will be the functions pa...") |
(→Return Value) |
||
Line 17: | Line 17: | ||
=== Return Value === | === Return Value === | ||
− | + | A function variable that can be called later when needed. | |
=== Remarks === | === Remarks === |
Revision as of 11:54, 22 January 2013
MKFunc ( <params>, <body> )
Contents |
Description
Create a user defined function to be called from a variable.
params
A string that will be the functions parameters.
body
A string that will be the functions body.
Return Value
A function variable that can be called later when needed.
Remarks
The body does not need a { } block it already includes one in the build.
Example
Simple hello world with no params
my $Func = MKFunc('', 'println("Hello World");'); CallFunc($Func);
One with params
my $Func = MKFunc('$a, $b', 'println("Value is: " . ($a + $b));'); CallFunc($Func, array(10, 20));
Same as above but this time using the function(){} statement instead of MKFunc
my $Func = Function(){ println("Hello World");}; CallFunc($Func); my $Func = Function( $a, $b ){ println("Value is: " . ($a + $b)); }; CallFunc($Func, array(10, 20));