Part of the standard trait_keyedForEach. When iterating an array in this manner, the pair's ->first value is the element position, while ->second is the element value.
array->foreachpair => { expression }
This example iterates through an array of names and outputs the position of the name in the array along with name.
Code
define listMe(p::pair) => {
return #p->first+'. '+#p->second
}
var( myNames = array('Tom' , 'Jen' , 'Cam' ))
$myNames->foreachpair => {^ listMe(#1)+'\n' ^}
Result
1. Tom 2. Jen 3. Cam
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