Classes: Difference between revisions

Content deleted Content added
→‎{{header|Tcl}}: improve style
Line 1,073: Line 1,073:
{{works with|Tcl|8.5}} and the [http://wiki.tcl.tk/TclOO TclOO package]
{{works with|Tcl|8.5}} and the [http://wiki.tcl.tk/TclOO TclOO package]
<lang Tcl>oo::class create summation {
<lang Tcl>oo::class create summation {
variable v
constructor {} {
constructor {} {
variable v 0
set v 0
}
}
method add x {
method add x {
variable v
incr v $x
incr v $x
}
}
method value {} {
method value {} {
variable v
return $v
return $v
}
}
destructor {
destructor {
variable v
puts "Ended with value $v"
puts "Ended with value $v"
}
}