# Array of objects

**URL:** <https://www.ruby-forum.com/t/array-of-objects/188896>\
**Category:** Rails\
**Created:** [May 20, 2010, 5:05am UTC](https://www.ruby-forum.com/t/array-of-objects/188896 "2010-05-20T05:05:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [May 20, 2010, 5:05am UTC](https://www.ruby-forum.com/t/array-of-objects/188896/1 "2010-05-20T05:05:09Z")

</div>

If you have an array of objects and you do

array\_of\_objects.each do |o|  
o.method  
end

Do the attributes of the object get passed to the method so you can  
access them?

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [May 20, 2010, 5:55am UTC](https://www.ruby-forum.com/t/array-of-objects/188896/2 "2010-05-20T05:55:28Z")

</div>

Sent from my iPhone

On May 19, 2010, at 8:04 PM, Me [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> If you have an array of objects and you do
> 
> array\_of\_objects.each do |o|  
> o.method  
> end
> 
> Do the attributes of the object get passed to the method so you can  
> access them?

The object’s attributes are available within the instance method. For  
example,

class MyClass

```
 attr_accessor :foo, :bar

 def some_method
     # access the attributes
     @foo = 1
      self.bar = "test"
 end

```

end

o.some\_method

I would recommend getting a copy of Programming Ruby.

Good luck,

-Conrad
