Version 0 of itcl::is

Updated 2006-07-15 15:01:48

Both itcl::is and itcl::isa are covered here.

itcl::is tests whether a variable is a class. Returns a boolean true or false.

itcl::isa tests whether a variable is derived from a class see Derived itcl::class. Returns a boolean.

  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]"