Jump to content

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

(→‎{{header|Perl 6}}: show shorthand mixin)
Line 171:
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.
 
#class Object
{
}
 
#class FieldContainer
Line 190 ⟶ 186:
#symbol Program =>
[
#var anObject := Object234.
// adding a field
anObject := #group(anObject, ~FieldContainer).
anObject set &foo:"bar".
'program'Output << anObject << ".foo=" << anObject foo.
].
</lang>
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.