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 13:31, 19 May 2009
, 15 years ago→{{header|Tcl}}: formatting tweak
m (→{{header|Tcl}}: having killed the nl in the works with template, a lot of "works with" will be on the same line instead of be stacked) |
m (→{{header|Tcl}}: formatting tweak) |
||
Line 273:
The code below uses the fact that each object is implemented as a namespace, to add a ''time'' variable to an instance of ''summation'':
<lang Tcl>% oo::class create summation {
constructor {} {
variable v 0
Line 297 ⟶ 296:
% set ${s}::time
now
%</lang>▼
▲</lang>
{{Omit From|AWK}}
|