Ball, Donald A Jr (Library)
6/15/2007 9:37:00 PM
> -----Original Message-----
> From: Greg Hauptmann [mailto:greg.hauptmann.ruby@gmail.com]
> Sent: Friday, June 15, 2007 4:35 PM
> To: ruby-talk ML
> Subject: accessing the count/iteration # within an "each" ???
>
> Hi,
>
> Is there a way to access the count / iteration# within an
> "each" loop? i.e.
> how many times through the loop one is?
>
> testhash.each { |d|
> puts <count>
>
> }
testhash.each_with_index {|d, i| puts i}
- donald