RosettaCodeData/Task/Associative-array-Creation/Langur/associative-array-creation....

13 lines
291 B
Plaintext

var .hash = h{1: "abc", "1": 789}
# may assign with existing or non-existing hash key (if hash is mutable)
.hash[7] = 49
writeln .hash[1]
writeln .hash[7]
writeln .hash["1"]
# using an alternate value in case of invalid index; prevents exception
writeln .hash[1; 42]
writeln .hash[2; 42]