Jump to content

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

→‎{{header|Tcl}}: Correction; do it the neater way!
m (→‎{{header|Tcl}}: formatting tweak)
(→‎{{header|Tcl}}: Correction; do it the neater way!)
Line 281:
incr v $x
}
method value {{var v}} {
variable v$var
return [set $vvar]
}
destructor {
Line 292:
::summation
% set s [summation new]
% # Do the monkey patch!
% set [info object namespace ${s}]::time now
now
% # Prove it's really part of the object...
% set ${s}::time
% $s value time
now
%</lang>
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.