Re: for loop and pairs question, explanation needed

2018-02-22 Thread r3d9u11
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 ;)).

Re: for loop and pairs question, explanation needed

2018-02-22 Thread boia01
The reason the first case is correct is because Nim implicitly calls `pairs` when the for loop has exactly 2 variables. See

Re: for loop and pairs question, explanation needed

2018-02-22 Thread Stefan_Salewski
> 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

for loop and pairs

2018-02-22 Thread r3d9u11
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