Ruby/Reflection/variable Reflection

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

(Различия между версиями)
Перейти к: навигация, поиск
м (1 версия: Импорт выборки материалов по Ruby)
 

Текущая версия на 17:57, 13 сентября 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