Lasso Soft Inc. > Home

[ map->forEach ]

Method

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

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

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

To perform an operation using the values of a map

Use the [map->forEach] method. This example outputs the capitalized values of a map.

Code

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


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

Result

#0000FF
#00FF00
#AAAAAA
#FF0000

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