Re: Syntax for OR
- Posted by DerekParnell (admin) Mar 04, 2015
- 1643 views
Lnettnay said...
katsmeow said...
Use parentheses liberally, they come free with each OE installation.
if seqConn[1] = (1 or 3) thenI tend to use equal() on everything, saves crashing from unequal sequence lengths and other nonsense.
Kat
I'm sorry Kat, but that isn't correct.
I'm sorry Lonny, but what isn't correct? The syntax is correct. The use of parenthesis is correct. The intended result maybe correct, if we knew what the code intended by the code. So without that sort of context, it would be presumptuous to assume that Kat's code is "incorrect".
Lnettnay said...
(1 or 3) = 1 -- so if seqConn[1] = 3 -- then seqConn[1] = (1 or 3) will be false
Lonny
But ...
(1 or 3) = 1 -- so if seqConn[1] = 1 -- then seqConn[1] = (1 or 3) will be true
So maybe you might have been more accurate to say something along the lines of ...
alternative said...
It is incorrect that if A = (B or C) ... is equivalent to if (A = B) or (A = C) then ..., however, the idea that using parenthesis to explicitly highlight your coding intentions is a good one.