Classes: Difference between revisions
Content deleted Content added
m →{{header|Visual Basic .NET}}: whitespace |
→{{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 { |
||
⚫ | |||
constructor {} { |
constructor {} { |
||
set v 0 |
|||
} |
} |
||
method add x { |
method add x { |
||
⚫ | |||
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" |
||
} |
} |