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

13 lines
291 B
Text
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
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]