instance_variable_set and get : instance_variable_set « Reflection « Ruby






instance_variable_set and get

o = Object.new
o.instance_variable_set(:@x, 0)   # Note required @ prefix
o.instance_variable_get(:@x)      # => 0
o.instance_variable_defined?(:@x) # => true

 

Related examples in the same category