Sent from my iPhone
On May 19, 2010, at 8:04 PM, Me
<chabgood-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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
> --
> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@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
> .
>
--
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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.