Logical not operator

Coming from the land of C / C ++ I'm wondering why the following doesn't work:

set a 111
if {! $a eq {} } {
  puts hi
}

      

I know if I change the 2nd line to if { $a ne {} } {

then it will be fine, but I can't wrap myself around why "!" does not work.

+3


source to share


1 answer


This is because it !

has higher precedence than in Tcl ne

, so it is evaluated first.



You can check this link for a complete list of Tcl operator priorities.

+5


source







All Articles