package require Itcl itcl::class helloworld { public variable owner "No-one" method greet {} { puts "Hello World from $owner" } } itcl::class goodbyeworld { public variable owner "No-one" method greet {} { puts "Goodbye Cruel World from $owner" } } helloworld h1 goodbyeworld h2 h1 configure -owner Me h2 configure -owner You h1 greet h2 greetThe following reports that both h1 and h2 are itcl objects.
puts "Variable h1 [itcl::is object h1] h2 [itcl::is object h2]"This snippet reports that h1 is a helloworld, but h2 is not.
puts "Variable h1 [itcl::is object h1 -class helloworld] h2 [itcl::is object h2 -class helloworld]"
A similar method "isa" has been added which returns a logical:
- h1 isa helloworld
puts "Hey [h1 isa helloworld]"
- Hey 1
puts "Hey [h1 isa goodbyeworld]"
- Hey 0
puts "Hey [h1 isa sausage]"
- class "sausage" not found in context "::helloworld"
h1 info class
- ::helloworld