cancel
Showing results for 
Search instead for 
Did you mean: 

flipping a boolean

Genius
Genius

So in many languages you can flip a boolean by the following statement:

var = ! var;

 

So if the boolean var = true, then after the statement it will be flipped to false. Is there something like this in PS? I looked through the help and the forum, but couldn't find anything.

 

I know I could just do:

if var = true

   var = false

else 

   var = true

end

 

But that is SOOO many lines of code! My RAM is precious you know.

 

Many thanks.

1 REPLY

Re: flipping a boolean

Genius
Genius

Sorry, I found it:

 

var := not var

 

"not" is the same as !