Thanks! (I was misled by string representation of pair. its string
representation is string representation of contained element. Also after
C/C++/C#/JS the syntax is still little bit unaccustomed for me, yet ;)).
The reason the first case is correct is because Nim implicitly calls `pairs`
when the for loop has exactly 2 variables.
See
> why first sample works?
Because it is correct.
pairs should give you a tuple, you can use it this way:
for index, item in ["a","b"]:
echo item, " at index ", index
for t in ["a","b"].pairs:
echo t[1], " at index ", t[0]
for index, t in
Hi. I have a little question: what differents between samples? And why first
sample works?
for index, item in ["a","b"]:
echo item, " at index ", index
# => a at index 0
# => b at index 1
for index, item in ["a","b"].pairs:
echo item, " at index ", index