Lasso Soft Inc. > Home

[ array->forEachKey ]

Method

Part of the standard trait_keyedForEach. Iterates over each "key", which is simply the positions for each element.

  • Syntax
array->foreachkey => { expression }
Examples
  • Beginner

Return the 'keys' of an array

This example returns a list of the squares of the keys (element positions) of an array.

Code

define squareMe(n::integer) => {  
    return #n * #n
}

var( myNames = array('Tom' , 'Jen' , 'Cam' ))

$myNames->foreachkey => {^  squareMe(#1)+' ' ^}

Result

1 4 9 

Recent Comments

No Comments found

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. > Home

 

 

©LassoSoft Inc 2014 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft