Associative array/Creation: Difference between revisions

(PascalABC.NET)
 
Line 3,933:
Hash keys in langur may be numbers or strings. Number keys are simplified, so that 1.0 is the same key as 1.
 
<syntaxhighlight lang="langur">var .hashh = {1: "abc", "1": 789}
 
# may assign with existing or non-existing hash key (if hash is mutable)
.hashh[7] = 49
 
writeln .hashh[1]
writeln .hashh[7]
writeln .hashh["1"]
 
# using an alternate value in case of invalid index; prevents exception
writeln .hashh[1; 42]
writeln .hashh[2; 42]</syntaxhighlight>
</syntaxhighlight>
 
{{out}}
1,007

edits