Reputation: 3235
Coming from C/C++ land, I am wondering why the following does not work:
set a 111
if {! $a eq {} } {
puts hi
}
I know if I change the 2nd line to if { $a ne {} } {
then it is fine, but cannot wrap my head around why "!" does not work.
Upvotes: 4
Views: 6592
Reputation: 7870
This is because in Tcl, !
has a higher precedence than ne
, so it is evaluated first.
You can check out this link for a complete list of Tcl operator precedence.
Upvotes: 7