> 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 ["a","b"].pairs:
      echo t
      echo t[1], " at index ", index, "==", t[0]
    
    
    
    $ ./t
    a at index 0
    b at index 1
    a at index 0
    b at index 1
    a
     at index 0==a
    b
     at index 1==b
    
    

The last loop does indeed not work as one may desire, but that loop would make 
no real sense, as it would give us the same index value in two different ways 
-- as part of the tuple and as index variable.

Reply via email to