Forum: Ruby on Rails Traversing an object / array?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F68e4842b0a5487678e26046fdb2fdf3?d=identicon&s=25 softwareengineer 99 (Guest)
on 2006-02-06 22:38
(Received via mailing list)
This is a very basic question but I cannot find the 'right' answer.

  What is the best way to traverse an object / array with ROR.

  I need to look at the structure of some of the objects/ arrays but not
sure how to go about it.

  I appreciate your assistance.

  Thanks
  Frank
B1102f65359ee629df508c7857f03b1c?d=identicon&s=25 Phillip Hutchings (Guest)
on 2006-02-06 23:21
(Received via mailing list)
On 7/02/2006, at 10:36 AM, softwareengineer 99 wrote:

> This is a very basic question but I cannot find the 'right' answer.
>
> What is the best way to traverse an object / array with ROR.
>
> I need to look at the structure of some of the objects/ arrays but
> not sure how to go about it.

For an array:

array.each do |item|
	// stuff with item
end

An object is trickier, they're not supposed to be traversed like an
array. Check out ruby-doc.org, the 1.8 reference documentation, the
interesting methods are in the Object and Module classes
This topic is locked and can not be replied to.