The [staticarray->forEach] method invokes a tag, type, or compound expression on each element in the array. The method requires a single parameter which is a tag reference, data type instance, or compound expression. The parameter is invoked on each element of the array in turn (i.e. the tag is called with each element of the array as a parameter in turn). The parameter must return True for the method to continue. If the parameter returns False then the operation is halted.
staticarray->forEach => {^ expression ^}
This example uses the [staticarray->forEach] method to output a list of squares of the elements of an array of numbers
Code
define squareMe(n::integer=1) => {
return #n * #n
}
var( an_array = staticarray(1, 2, 3, 4))
$an_array->foreach => {^ squareMe(#1)+' ' ^}
Result
1 4 9 16
Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft
Recent Comments