Jump to content

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

No edit summary
Line 118:
 
=={{header|Falcon}}==
Classes and singleton objects have a fixed structure which cannot be changed during runtime. However falcon does have capability to add variables/functions at runtime with Prototype based objects. Below are two of the prototype objects that allow adding variables at runtime. These are arrays and dictionaries (hashes for the perl type out there).<br><br>
'''Array:'''
In this example we add a function (which prints out the content of the array) and a new value. While we are not technically adding a "variable", this example is presented to show similar type of functionality.
Line 132:
</lang>
'''Dictionary:'''
In this example we create an object from a bless'ed dictionary. We assign aan external, to the object, function (sub_func) to the variable 'addsub'. Additionally create a new variable called 'newVar' at runtime and assign a string to it.
<lang falcon>
function sub_func( value )
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.