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 10:19, 25 November 2009
, 14 years agoMathematica
m (Fixed lang tags.) |
(Mathematica) |
||
Line 146:
<lang lua>empty = {}
empty.foo = 1</lang>
=={{header|Mathematica}}==
Mathematica doesn't rally have classes, so it doesn't have class variables. However, many rules can be applied to a single tag, so it has some aspects similar to a class. With that definition, adding a class variable is similar to adding a rule:
<lang Mathematica>
f[a]=1;
f[b]=2;
f[a]=3;
? f</lang>
Global`f
f[a]=3
f[b]=2
Here, the two 'variables' can be seen under the single heading 'f'. And of course all of this is done at runtime.
=={{header|Perl}}==
|