Associative array/Iteration: Difference between revisions

Added Wren
(Rename Perl 6 -> Raku, alphabetize, minor clean-up)
(Added Wren)
Line 3,477:
<pre>a 1
b 2</pre>
 
=={{header|Wren}}==
Note that Wren makes no guarantee about iteration order which is not necessarily the same order in which the entries were added.
<lang ecmascript>// create a new map with four entries
var capitals = {
"France": "Paris",
"Germany": "Berlin",
"Russia": "Moscow",
"Spain": "Madrid"
}
 
// iterate through the map and print out the key/value pairs
for (c in capitals) System.print([c.key, c.value])
System.print()
 
// iterate though the map and print out just the keys
for (k in capitals.keys) System.print(k)
System.print()
 
// iterate though the map and print out just the values
for (v in capitals.values) System.print(v)</lang>
 
{{out}}
<pre>
[France, Paris]
[Russia, Moscow]
[Germany, Berlin]
[Spain, Madrid]
 
France
Russia
Germany
Spain
 
Paris
Moscow
Berlin
Madrid
</pre>
 
=={{header|XPL0}}==
9,476

edits