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

No edit summary
Line 325:
 
=={{header|Elena}}==
ELENA does not support adding a field at run-time but it can be simulated with the help of a group objectmix-in.
ELENA 3.x
<lang elena>#define system.
<lang elena>#defineimport extensions.
 
#class Extender :: BaseExtender
{
#fieldobject theField.
#constructor new : anObject
[
theObject := anObject.
]
#method foo = theField.
#method set &foo : aValue
[
theField := aValue.
Line 346:
}
 
#symbol program =
[
#var anObject := 234.
// extending an object with a field
Anonymous user