# Traversing an object / array?

**URL:** <https://www.ruby-forum.com/t/traversing-an-object-array/101751>\
**Category:** Rails\
**Created:** [February 6, 2006, 10:38pm UTC](https://www.ruby-forum.com/t/traversing-an-object-array/101751 "2006-02-06T22:38:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![softwareengineer\_99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b782af/32.png) [@softwareengineer\_99](https://www.ruby-forum.com/u/softwareengineer_99)\
**Post date:** [February 6, 2006, 10:38pm UTC](https://www.ruby-forum.com/t/traversing-an-object-array/101751/1 "2006-02-06T22:38:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![softwareengineer\_99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/b782af/32.png) [@softwareengineer\_99](https://www.ruby-forum.com/u/softwareengineer_99)\
**Post date:** [February 6, 2006, 11:21pm UTC](https://www.ruby-forum.com/t/traversing-an-object-array/101751/2 "2006-02-06T23:21:04Z")

</div>

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](http://ruby-doc.org), the 1.8 reference documentation, the  
interesting methods are in the Object and Module classes
