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?
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
endDo 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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs