Null object: Difference between revisions
Content added Content deleted
(→{{header|Pascal}}: should redirect to an anchor in the same page, not to some other page.) |
|||
Line 595: | Line 595: | ||
<lang PicoLisp>(unless MyNewVariable |
<lang PicoLisp>(unless MyNewVariable |
||
(handle value-is-NIL) )</lang> |
(handle value-is-NIL) )</lang> |
||
=={{header|Pike}}== |
|||
In Pike all variables are initialized to <math>0</math>, regardless of their type. thus <math>0</math> functions as a <code>Null</code> value for all types except integer. |
|||
<math>0</math> is also used to indicate the absence of a key or object member. |
|||
to tell the difference between a value <math>0</math> and absence of a key, <code>zero_type()</code> is used: |
|||
<lang Pike>> mapping bar; |
|||
> bar; |
|||
Result: 0 |
|||
> bar = ([ "foo":0 ]); |
|||
> bar->foo; |
|||
Result 0; |
|||
> zero_type(bar->foo); |
|||
Result: 0 |
|||
> bar->baz; |
|||
Result: 0 |
|||
> zero_type(bar->baz); |
|||
Result: 1</lang> |
|||
=={{header|PL/I}}== |
=={{header|PL/I}}== |