Associative array/Creation: Difference between revisions

added Fantom example
(Add Brat solution)
(added Fantom example)
Line 1,245:
[ [ 3 "three" ] dip set-at ]
[ "three" swap at . ] } cleave</lang>
 
=={{header|Fantom}}==
 
Associative arrays are called 'maps' in Fantom:
 
<lang fantom>
class Main
{
public static Void main ()
{
// create a map which maps Ints to Strs, with given key-value pairs
Int:Str map := [1:"alpha", 2:"beta", 3:"gamma"]
 
// create an empty map
Map map2 := [:]
// now add some numbers mapped to their doubles
10.times |Int i|
{
map2[i] = 2*i
}
 
}
}
</lang>
 
=={{header|Forth}}==
342

edits