Add a variable to a class instance at runtime: Difference between revisions

m
m (→‎{{header|Ada}}: Another case problem)
m (→‎{{header|Ruby}}: lang tag)
Line 187:
 
=={{header|Ruby}}==
<lang ruby> class Empty
end
 
Line 193:
e.instance_variable_set("@foo", 1)
e.instance_eval("class << self; attr_accessor :foo; end")
puts e.foo</lang>