[olug] testing order in elif

Christopher Cashell topher-olug at zyp.org
Wed Mar 12 04:20:10 UTC 2008


On Tue, Mar 11, 2008 at 10:34 PM, 02fun-u2 <02fun-u2 at excite.com> wrote:
>
>  when using elif to test a condition does elif test every condition or just match the first one and do the requested action and quit processing any other part of the elif…. Like linux ipfilter tables

elif is short for "else if".  It will always check the first if, and
after that, it works it's way down the elif's only if the preceding
one fails (hence the "else").  It can be read as:

if the first condition is true,
then do this stuff;
else, if the second condition is true,
then do this other stuff,
else, if the third condition is true,
then do this other other stuff.

-- 
Christopher



More information about the OLUG mailing list