Null object: Difference between revisions

Content added Content deleted
Line 89: Line 89:


=={{header|Babel}}==
=={{header|Babel}}==
In this example, we place nil on the stack, then perform an if-then-else (ifte) based on the value returned by the 'nil?' operator which returns true of top-of-stack (TOS) is nil. If TOS is nil, then we can be relieved, otherwise, the interpreter has gone absolutely haywire. The '<<' operator prints the selected string to STDOUT.
In this example, we place nil on the stack, then perform an if-then-else (ifte) based on the value returned by the 'nil?' operator which returns true if top-of-stack (TOS) is nil. If TOS is nil, then we can be relieved, otherwise, the interpreter has gone absolutely haywire. The '<<' operator prints the selected string to STDOUT.
<lang babel>{ nil { nil? } { "Whew!\n" } { "Something is terribly wrong!\n" } ifte << }</lang>
<lang babel>{ nil { nil? } { "Whew!\n" } { "Something is terribly wrong!\n" } ifte << }</lang>