Core Function CallFunc
From Sputnik Wiki
(Difference between revisions)
(→array) |
(→Example) |
||
Line 44: | Line 44: | ||
my $Func = Function( $a, $b ){ println("Value is: " . ($a + $b)); }; | my $Func = Function( $a, $b ){ println("Value is: " . ($a + $b)); }; | ||
CallFunc($Func, array(10, 20)); | CallFunc($Func, array(10, 20)); | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | Same as above but this time calling directly instead of using CallFunc | ||
+ | |||
+ | <syntaxhighlight lang="sputnik"> | ||
+ | my $Func = Function( $a, $b ){ println("Value is: " . ($a + $b)); }; | ||
+ | $Func(10, 20); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category:Core Function]] | [[Category:Core Function]] |
Revision as of 08:52, 26 August 2013
CallFunc( <function>, <array> )
Contents |
Description
Calls a user defined function contained in a variable.
function
The function name.
array
Optional; An array to send the function as the parameters.
Return Value
Returns whatever the function returns.
Remarks
None.
Example
my $Func = MKFunc('', 'println("Hello World");'); CallFunc($Func);
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));
Same as above but this time calling directly instead of using CallFunc
my $Func = Function( $a, $b ){ println("Value is: " . ($a + $b)); }; $Func(10, 20);