Add a variable to a class instance at runtime: Difference between revisions
Content added Content deleted
(→{{header|Kotlin}}: Updated example see https://github.com/dkandalov/rosettacode-kotlin for details) |
|||
Line 326: | Line 326: | ||
=={{header|Elena}}== |
=={{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 does not support adding a field at run-time but it can be simulated with the help of a mix-in. |
||
ELENA 3. |
ELENA 3.1 |
||
<lang elena> |
<lang elena>import extensions. |
||
class Extender :: BaseExtender |
class Extender :: BaseExtender |
||
{ |
{ |
||
object |
object foo :: prop(theField). |
||
constructor new : anObject |
constructor new : anObject |
||
Line 346: | Line 346: | ||
anObject := Extender new:anObject. |
anObject := Extender new:anObject. |
||
anObject |
anObject foo := "bar". |
||
console |
console printLine:anObject:".foo=":(anObject foo). |
||
console readChar. |
console readChar. |