Posted to tcl by cchase at Fri May 27 17:14:36 GMT 2022view raw
- oo::class create Person {
- variable name
- variable age
- method setName {args} {
- lassign $args name rest
- puts "Name set to $name"
- variable name $name
- if {[llength $rest] > 0} {
- my {*}$rest
- }
- }
- method setAge {args} {
- lassign $args age rest
- puts "Age set to $age"
- variable age $age
- if {[llength $rest] > 0} {
- my {*}$rest
- }
- }
- method details {} {
- variable name
- variable age
- puts "$name is $age years old"
- }
- }
- Person create guy
- guy setName Bob {setAge 33}