I have an array:
r1.rp_parts:
[<Rp1....>][<Rp1....>][<Rp1....>][<Rp4....>]
If I do:
r1.rp_parts[2]
I obtain
Rp1...
I would like to obtain de position of r1.rp_parts[2] in the r1.rp_parts
array. I know that it''s position is 2, but I wonder if I can obtain the
position from r1.rp_parts[2].
--
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
John Smith wrote:> I have an array: > > r1.rp_parts: > [<Rp1....>][<Rp1....>][<Rp1....>][<Rp4....>] > > If I do: > r1.rp_parts[2] > I obtain > Rp1... > > I would like to obtain de position of r1.rp_parts[2] in the r1.rp_parts > array. I know that it''s position is 2, but I wonder if I can obtain the > position from r1.rp_parts[2].Use the index method of Array: some_part = r1.rp_parts[2] r1.rp_parts.index(some_part) #=> 2 -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---