Null object: Difference between revisions
Content added Content deleted
(Added Maple implementation.) |
(Lingo added) |
||
Line 744: | Line 744: | ||
#y->type == 'null' |
#y->type == 'null' |
||
//true</lang> |
//true</lang> |
||
=={{header|Lingo}}== |
|||
Null/nil is called "<Void>" in Lingo. Lingo doesn't distinguish undefined variables from <Void> objects, and by using the constant VOID you can even assign <Void> to variables. Functions that don't return anything, return <Void>. Checking for <Void> (e.g. by using built-in function voidP) can also be used to implement optional function arguments: if voidP() returns TRUE (1) for some argument, a default value can be assigned in the function body. |
|||
<lang lingo>put _global.doesNotExist |
|||
-- <Void> |
|||
put voidP(_global.doesNotExist) |
|||
-- 1 |
|||
x = VOID |
|||
put x |
|||
-- <Void> |
|||
put voidP(x) |
|||
-- 1</lang> |
|||
=={{header|Lily}}== |
=={{header|Lily}}== |