Core Function Call
From Sputnik Wiki
(Difference between revisions)
(→Example) |
|||
Line 38: | Line 38: | ||
println("Hello from test ($a, $b)"); | println("Hello from test ($a, $b)"); | ||
} | } | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | Example of using the first param as an array to call stuff within classes etc | ||
+ | |||
+ | <syntaxhighlight lang="sputnik"> | ||
+ | Class Testy | ||
+ | { | ||
+ | Function __Construct() | ||
+ | { | ||
+ | Call( array($this, "Test"), 10, 20); | ||
+ | } | ||
+ | |||
+ | Function Test($a, $b) | ||
+ | { | ||
+ | println("Hello from test ($a, $b)"); | ||
+ | } | ||
+ | }; | ||
+ | my $newTesty = new Testy(); | ||
</syntaxhighlight> | </syntaxhighlight> | ||
[[Category:Core Function]] | [[Category:Core Function]] |
Revision as of 15:53, 20 January 2013
Call <function/array>, <expressions>
Contents |
Description
Calls a function contained in a string parameter.
function
The name of the user function to call.
OR
A two element array to use as the call class and function name.
expressions
None, One or more arguments to send to the function.
Return Value
Acts like a regular function call.
Remarks
The function CAN be a built-in Sputnik function or a user defined one.
The function can pass arguments to functions, also & pointer parameters are supported.
Example
Call( "Test", 10, 20); Function Test($a, $b) { println("Hello from test ($a, $b)"); }
Example of using the first param as an array to call stuff within classes etc
Class Testy { Function __Construct() { Call( array($this, "Test"), 10, 20); } Function Test($a, $b) { println("Hello from test ($a, $b)"); } }; my $newTesty = new Testy();