Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Logical not operator

Tags:

tcl

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.

like image 663
my_question Avatar asked Nov 06 '25 17:11

my_question


1 Answers

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.

like image 195
Peter Pei Guo Avatar answered Nov 10 '25 16:11

Peter Pei Guo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!