ID:1442313
 
(See the best response by Kaiochao.)
if(src.key in admin || src.key in head_moderator || src.key in moderator)


So, I've been wondering for a while now. I am in "admin" and it doesn't represent this if statement as true. Why? What am I doing wrong?

Exactly how does the || and | operators work? I never bothered to get deep in to them. I just used them in simple if statements. Every now and then I pull a miracle and they do what I want them to do.

Best response
You need to surround your "in" expressions with parentheses. Due to order of operations, "in" works after || does.

Like all operators, || takes a number of inputs (2, a left and right) and returns an output (the first value from left to right that passes as true).

The | operator deals with bits, or binary numbers. When you're dealing with just TRUE and FALSE (which is what the "in" operator returns), it's pretty much equivalent to the || operator, but it doesn't work for non-numbers.
Agh.. So simple.. Yet I've done it countless times and never remember. Thanks. The parenthesis is all that made me confused as to how they work.
If you are interested, here are some links to the entries which state the order of operations in DM:
DM Ref (operators)
DM Guide (Section 16, Fig. 6.12)

^_^