The [delve->foreach] method invokes a capture block on each element in the delve. The method requires a capture block to be passed to it. The capture block is invoked on each element of the delve in turn (i.e. the capture block is invoked with each element of the delve). The current value in the delve can be accessed using the #1 variable.
#myDelve->forEach => {
}
This example calculates the sum of each item in the delve. The sum is output.
Code
local( total = 0 );
local( arr = array( 1, 2, (: 3, 4, 5 ), list( 6, 7 ), array( 8, 9 ) ) );
delve( #arr )->forEach => {
#total += #1;
} // Close forEach
#total;
Result
45
This example calculates the sum of each item in the delve. The sum is output.
Code
local( total = 0 );
local( arr = array( 1, 2, (: 3, 4, 5 ), list( 6, 7 ), array( 8, 9 ) ) );
delve( #arr )->forEach => {
#total += #1;
} // Close forEach
#total;
Result
45
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