Add a variable to a class instance at runtime: Difference between revisions
Content deleted Content added
m →{{header|Ada}}: Another case problem |
m →{{header|Ruby}}: lang tag |
||
Line 187: | Line 187: | ||
=={{header|Ruby}}== |
=={{header|Ruby}}== |
||
<lang ruby> class Empty |
|||
end |
end |
||
Line 193: | Line 193: | ||
e.instance_variable_set("@foo", 1) |
e.instance_variable_set("@foo", 1) |
||
e.instance_eval("class << self; attr_accessor :foo; end") |
e.instance_eval("class << self; attr_accessor :foo; end") |
||
puts e.foo |
puts e.foo</lang> |