Joshua Muheim wrote:
> Hi all
> 
> Is there a method to iterate over an array with the index? Something
> like
> 
> my_array.each_with_index do |obj, index|
>   ...
> end
> 
> Just couldn't find such a method... maybe I worked too much today... ;-)
> 
> Thanks
> Josh

Hi Josh,

I agree that you worked too much today. Ruby's Enumerable class has that 
exact method.

>> [1, 2].respond_to?(:each_with_index)
=> true

Peace.
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to