Add a variable to a class instance at runtime: Difference between revisions
Content added Content deleted
(→{{header|Smalltalk}}: commented the wrong example (long time passed since and original author did not care)) |
|||
Line 1,657: | Line 1,657: | ||
then, again create a 2D Point object, add a z slot, change and retrieve the z-value, finally inspect it (and see the slots). |
then, again create a 2D Point object, add a z slot, change and retrieve the z-value, finally inspect it (and see the slots). |
||
<lang smalltalk>p := Point x:10 y:20. |
<lang smalltalk>p := Point x:10 y:20. |
||
p addSlot:'z'. |
p addSlot:'z'. "instance specific added slot" |
||
p z:30. |
p z:30. |
||
p z. |
p z. |