Anonymous user
Add a variable to a class instance at runtime: Difference between revisions
Add a variable to a class instance at runtime (view source)
Revision as of 09:19, 31 October 2009
, 14 years agoUndo revision 67005 by 164.67.199.150 (Talk)Maybe discuss before invalidating other entries?
No edit summary |
(Undo revision 67005 by 164.67.199.150 (Talk)Maybe discuss before invalidating other entries?) |
||
Line 1:
{{task|Object oriented}}
This demonstrates how to dynamically add variables to a class instance at runtime. This is useful when the methods/variables are based on a data file that isn't available until runtime. Hal Fulton gives an example of creating an OO CSV parser at [http://www.devsource.com/article2/0,1759,1928562,00.asp An Exercise in Metaprogramming with Ruby]. This is referred to as "monkeypatching" by Pythonistas and some others. It's possible in most '''dynamic''' OO languages such as Python, Ruby, and Smalltalk.
=={{header|ActionScript}}==
|