Core Function Walk
From Sputnik Wiki
(Difference between revisions)
(→Return Value) |
|||
Line 21: | Line 21: | ||
Success - Returns unknown. | Success - Returns unknown. | ||
− | Failure - Returns | + | Failure - Returns false. |
=== Remarks === | === Remarks === |
Revision as of 22:58, 25 August 2013
Walk( <array>, <function> )
Contents |
Description
Walk through the arrays items and execute a user defined function on each one.
Parameters
array
The array to use.
function
A user defined function literal or variable containing one.
Return Value
Success - Returns unknown.
Failure - Returns false.
Remarks
None.
Example
my $myarray = array(10, 20, 30, 40, 50, 60, 70); $ret = Walk($myarray, function($value){++$value;}); println("Walk returned: $ret"); printr($myarray);
Same as above
my $myarray = array(10, 20, 30, 40, 50, 60, 70); my $func = function($value) { println("Got value $value adding to it now..."); ++$value; }; $ret = Walk($myarray, $func); println("Walk returned: $ret"); printr($myarray);