Re: Syntax for OR

new topic     » goto parent     » topic index » view thread      » older message » newer message
DerekParnell said...
cp said...

It seems that this syntax is supported ?

if seqConn[1] = 1 or 3 then 

and is equivalent to..

if seqConn[1] = 1 or seqConn[1] = 3 then 

casey

As said by others, this type of shortcut is not supported. The operator precedence rules means that in the absence of parenthesis,

if seqConn[1] = 1 or 3 then 

and is really equivalent to..

if (seqConn[1] = 1) or (3) then 

or to use really longhand ...

if (seqConn[1] = 1) then 
   ... 
elsif (3) then 
   ...   
end if 

But the problem is that those two code segments are not equivalent!

if (seqConn[1] = 1) or (3) then 

will always be true but

if (seqConn[1] = 1) then 
   ... -- path A 
elsif (3) then 
   ... -- path B  
end if 

will only execute path A if seqConn[1] = 1 and will execute path B in all other cases.

Lonny

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu