Boolean operator

I am copying a code that uses a Boolean operator which I cannot find on my key board. The Boolean Operator looks like two straight vertical dashes and is being used in a" if " control operator.

Mine is above the enter key.

||

You can also say "or", as in

if (a==b or c==d)

the same as

if (a==b || c==d)

Similarly, "and" for &&.

It took them years. Sigh.

Edit - corrected errors

Yes, but when 'or' became a keyword it can't be a variable name which will break old code.

BTW, you have to type two, the key produces one |, so you need to hit it twice. Also, on my keyboard it is shown with a gap in the middle for some reason, so it looks like a malformed colon.

And please don't use

a=b

which will assign the value of b to a - but is perfectly legal to use as is.

Instead, use

a==b

KeithRB:
Yes, but when ‘or’ became a keyword it can’t be a variable name which will break old code.

Boo hoo. :slight_smile:

That's the "pipe" symbol, on US keyboards its [SHIFT] + [BACKSLASH]. In unix shells its used to "pipe" the output of one command into the input of another, as in:

dmesg | less

KeithRB: ... so it looks like a malformed colon.

yikes... you have a proctologist's eye.

;)

KeithRB: Yes, but when 'or' became a keyword it can't be a variable name which will break old code.

They made 'or' a keyword‽ What is this kindergarten-grade madness‽

On my keyboard (azerty) it's AltGr + 6

aarg: You can also say "or", as in

if (a=b or c=d);

the same as

if (a=b || c=d);

Similarly, "and" for &&.

It took them years. Sigh.

You mean:

if (a==b or c==d)

No semicolon, and two of ==.

Please correct your earlier post.