Array of objects

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?

Sent from my iPhone

On May 19, 2010, at 8:04 PM, Me [email protected] 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