itcl::is tests whether a variable is a class. Returns a boolean true or false.
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 greet
The 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:
puts "Hey [h1 isa helloworld]"
puts "Hey [h1 isa goodbyeworld]"
puts "Hey [h1 isa sausage]"
And see also info which returns a string:
h1 info class