Draif Kroneg
Draif Kroneg

Reputation: 783

Negation operation in TCL

I have not managed to find out how to negate booleans in TCL... I tried:

set x true
puts !$x   #prints '!true'
puts ![$x] #prints !
puts [!$x] #prints no event matches "true"
puts !{$x} #prints !{true}
puts {!$x} #prints !$x

Upvotes: 7

Views: 5927

Answers (1)

glenn jackman
glenn jackman

Reputation: 247250

Logical 'not' is an arithmetic operator, so you need expr

% set x true
true
% puts [expr {!$x}]
0
% puts [expr {!!$x}]
1

Upvotes: 7

Related Questions