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

Content added Content deleted
(→‎{{header|Perl 6}}: show shorthand mixin)
Line 171: Line 171:
ELENA does not support adding a variable at run-time but it can be simulated with the help of a group object
ELENA does not support adding a variable at run-time but it can be simulated with the help of a group object
<lang elena>#subject foo.
<lang elena>#subject foo.

#class Object
{
}


#class FieldContainer
#class FieldContainer
Line 190: Line 186:
#symbol Program =>
#symbol Program =>
[
[
#var anObject := Object.
#var anObject := 234.
// adding a field
// adding a field
anObject := #group(anObject, FieldContainer).
anObject := anObject~FieldContainer.
anObject set &foo:"bar".
anObject set &foo:"bar".
'program'Output << anObject foo.
'program'Output << anObject << ".foo=" << anObject foo.
].
].
</lang>
</lang>