J
John Sayeau
If I have a people class with instance variables @name @age and @gender
and an instance of that class called peep (justa an example).
If I want to see all the available instance variables I can do:
p peep.instance_variables => ["@age", "@name", "@gender"]
Is there a way to get the value of those instance variables for the peep
instance without calling a class method ? Say there is full r/w access
to the instance variables.
Something like:
peep.instance_variables.each do |var|
var.(display value somehow)
end
Thanks.
and an instance of that class called peep (justa an example).
If I want to see all the available instance variables I can do:
p peep.instance_variables => ["@age", "@name", "@gender"]
Is there a way to get the value of those instance variables for the peep
instance without calling a class method ? Say there is full r/w access
to the instance variables.
Something like:
peep.instance_variables.each do |var|
var.(display value somehow)
end
Thanks.