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

m
→‎{{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 {
% oo::class create summation {
constructor {} {
variable v 0
Line 297 ⟶ 296:
% set ${s}::time
now
%</lang>
%
</lang>
 
{{Omit From|AWK}}
Anonymous user