Associative array/Iteration: Difference between revisions

Updated to work without warning with version 1.4 of Nim.
(→‎{{header|AWK}}: gawk allows sorting)
(Updated to work without warning with version 1.4 of Nim.)
Line 2,207:
import tables
 
var t: Table[int,string] = initTable[int,string]()
 
t[1] = "one"
t[2] = "two"
t[3] = "three"
t.add([4,] = "four")
 
echo "t has " & $t.len & " elements"
Line 2,224:
echo "at[" & $k & "]=" & t[k]
 
#itetateiterate pairs
echo "pair iteration:"
for k,v in t.pairs:
Anonymous user