Copyright (C) 2000-2012 |
GNU Info (gawk.info)Truth ValuesTrue and False in `awk' ======================= Many programming languages have a special representation for the concepts of "true" and "false." Such languages usually use the special constants `true' and `false', or perhaps their uppercase equivalents. However, `awk' is different. It borrows a very simple concept of true and false from C. In `awk', any nonzero numeric value _or_ any non-empty string value is true. Any other value (zero or the null string `""') is false. The following program prints `A strange truth value' three times: BEGIN { if (3.1415927) print "A strange truth value" if ("Four Score And Seven Years Ago") print "A strange truth value" if (j = 57) print "A strange truth value" } There is a surprising consequence of the "nonzero or non-null" rule: the string constant `"0"' is actually true, because it is non-null. (d.c.) automatically generated by info2www version 1.2.2.9 |