Reputation: 3103
In a namespace, it is very easy, for the sake of lazy evaluation, find if a namespace variable exists, from within the namespace:
info exists [ namespace current]::<var name>
How can I achieve the same for an instance of class, using Tcl OO?
I use TCL 8.6
Thanks.
Upvotes: 0
Views: 1058
Reputation: 13252
You can use
info exists [self namespace]::<var name>
or
expr {<var name> in [info class variables <class name>]}
if {<var name> in [info class variables <class name>]} {
...
}
Documentation: expr, if, in (operator), info, self (class configuration prefix), self
Upvotes: 1