Buy the book!
|[ < ]||[ > ]||[ << ]||[ Up ]||[ >> ]||[Top]||[Contents]||[Index]||[ ? ]|
else statement is
statement. It looks like this:
if (condition) then-body [else else-body]
The condition is an expression that controls what the rest of the
statement does. If the condition is true, then-body is
executed; otherwise, else-body is executed.
else part of the statement is
optional. The condition is considered false if its value is zero or
the null string; otherwise, the condition is true.
Refer to the following:
if (x % 2 == 0) print "x is even" else print "x is odd"
In this example, if the expression `x % 2 == 0' is true (that is,
if the value of
x is evenly divisible by two), then the first
else keyword appears on the same line as then-body and
then-body is not a compound statement (i.e., not surrounded by
curly braces), then a semicolon must separate then-body from
To illustrate this, the previous example can be rewritten as:
if (x % 2 == 0) print "x is even"; else print "x is odd"
If the `;' is left out,
awk can't interpret the statement and
it produces a syntax error. Don't actually write programs this way,
because a human reader might fail to see the
else if it is not
the first thing on its line.
|webmaster donations bookstore||delorie software privacy|
|Copyright © 2003 by The Free Software Foundation||Updated Jun 2003|