Lasso Soft Inc. > Home

[ map->forEachPair ]

Method

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

[map->forEachPair] returns each of the key/value pairs of the map. To return only the keys or values for each pair use either the [map->forEachKey] or the [map->forEach] method respectively

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

To perform an operation on each of the key/value pairs in a map

Use the [map->forEachPair] method. In this example a table of the key/value pairs of the 'colours' map.

Code

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

'<table border="1">'
$colours->forEachPair => {^
    '<tr>
         <td>'+#1->first+'</td>
         <td>'+#1->second+'</td>
     </tr>'
^}
'</table>'

Result

blue #0000ff
green #00ff00
grey #aaaaaa
red #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