Jump to content

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

Slate implementation
(omits)
(Slate implementation)
Line 194:
e.instance_eval("class << self; attr_accessor :foo; end")
puts e.foo</lang>
 
=={{header|Slate}}==
Slate objects are prototypes:
<lang slate>
define: #Empty -> Cloneable clone.
define: #e -> Empty clone.
e addSlotNamed: #foo valued: 1.
</lang>
 
=={{header|Smalltalk}}==
Cookies help us deliver our services. By using our services, you agree to our use of cookies.