Jump to content

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

(→‎{{header|Kotlin}}: Updated example see https://github.com/dkandalov/rosettacode-kotlin for details)
Line 326:
=={{header|Elena}}==
ELENA does not support adding a field at run-time but it can be simulated with the help of a mix-in.
ELENA 3.x1
<lang elena>#import extensions.
 
class Extender :: BaseExtender
{
object prop(foo) :: prop(theField).
constructor new : anObject
Line 346:
anObject := Extender new:anObject.
 
anObject set &foo := "bar".
 
console writeLineprintLine:anObject:".foo=":(anObject foo).
 
console readChar.
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.