ERights Home elang / blocks 
Back to: The && Expression On to: Nested Block Expression

The || Expression



left-expression || right-expression

As is familiar, this evaluates the left-expression to a boolean. If left is true, the answer is true and the right-expression isn't evaluated. If the left is false, then the answer is the right-expression evaluated to a boolean.

The || expression is one of two exceptions to the default scoping rules. (The other is the for-loop expression) Since a condition only produces useful bindings when it's true, only the left or right of an || can produce useful bindings. Therefore, we allow both left and right to define variables of the same names. The names introduced by left are not visible by right, but all the names introduced by either are visible following the || expression. In

 if (nm =~ `@base.c` || nm =~ `@base.h`) {

the then-expression will be evaluated whether nm is a .c file or a .h file, and in either case, base will be bound to the part before the dot.

*** expansion to kernel

 
Unless stated otherwise, all text on this page which is either unattributed or by Mark S. Miller is hereby placed in the public domain.
ERights Home elang / blocks 
Back to: The && Expression On to: Nested Block Expression
Download    FAQ    API    Mail Archive    Donate

report bug (including invalid html)

Golden Key Campaign Blue Ribbon Campaign