Ruby/Reflection/variable Reflection

Материал из Wiki.crossplatform.ru

Версия от 17:10, 26 мая 2010; (Обсуждение)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

method instance_variables returns the names of any instance variables associated with an instance (as opposed to class variables)

class Person
  attr_accessor :name, :age
end
p = Person.new
p.name = "Fred"
p.age = 20
puts p.instance_variables.inspect