On Mon, May 31, 2010 at 9:53 PM, Robert Klemme
<shortcutter / googlemail.com> wrote:
> Because it is closer on what OP initially did:

LOL. ok i get it :)
i was just pointing out how to retrieve the index (and the relevance
of it). i wouldn't want to "give" him *the* answer because i think
rubyist _are_ programmers...

kind regards -botp

> irb(main):001:0> [5, 7].each_with_index.each {|*a| p a}
> [5, 0]
> [7, 1]
> => [5, 7]

or simply,

=> [5, 7].each_with_index{|*a| p a}
[5, 0]
[7, 1]
=> [5, 7]


> This means that in your code the index cannot get lost along the way
> simply because it is added in the last step and not in the initial
> step.

shouldn't the programmer be the judge for that?

eg, i can easily scale if i need the square and the index...

> [5, 7].map{|a| a*a }.each_with_index{|*a| p a}
[25, 0]
[49, 1]

> Kind regards
> robert

best regards
-botp