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

13 lines
262 B
Text
Raw Permalink Normal View History

2024-07-13 15:19:22 -07:00
var h = {1: "abc", "1": 789}
2023-07-01 11:58:00 -04:00
# may assign with existing or non-existing hash key (if hash is mutable)
2024-07-13 15:19:22 -07:00
h[7] = 49
2023-07-01 11:58:00 -04:00
2024-07-13 15:19:22 -07:00
writeln h[1]
writeln h[7]
writeln h["1"]
2023-07-01 11:58:00 -04:00
# using an alternate value in case of invalid index; prevents exception
2024-07-13 15:19:22 -07:00
writeln h[1; 42]
writeln h[2; 42]