Lasso Soft Inc. > Home

[ map->forEachKey ]

Method

The [map->forEachKey] method iterates through a map allowing an operation to be performed on each element of the map in turn.

[map->forEachKey] returns the key of each of the key/value pairs of the map. This method is the compliment to the [map->forEach] method which returns the values of the map elements. If you need to perform operations on the entire map element use the [map->forEachPair] method.

  • Syntax
map->forEachKey => {^   ^}
Examples
  • Beginner

To perform an operation using the keys of a map

Use the [map->forEachKey] method. This example outputs the capitalized keys of a map.

Code

var (colours = map( 'red'='#ff0000',
                     'green' = '#00ff00',
                     'blue' = '#0000ff',
                     'grey' = '#aaaaaa') )

$colours->forEachKey => {^
     #1->uppercase
     #1+'\n'
^}

Result

BLUE
GREEN
GREY
RED

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 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft