Null object: Difference between revisions
Content added Content deleted
No edit summary |
No edit summary |
||
Line 44: | Line 44: | ||
COMMENT using the UNESCO/IFIP/WG2.1 ALGOL 68 character set |
COMMENT using the UNESCO/IFIP/WG2.1 ALGOL 68 character set |
||
result := °; |
result := °; |
||
IF REF STRING(result) : |
IF REF STRING(result) :?: ° THEN print(("result ? °", new line)) FI; |
||
END COMMENT |
END COMMENT |
||
Line 201: | Line 201: | ||
=={{header|Haskell}}== |
=={{header|Haskell}}== |
||
Haskell does not have a universal null value. There is a 'value of every type', the undefined value (sometimes written |
Haskell does not have a universal null value. There is a 'value of every type', the undefined value (sometimes written ?, 'bottom'), but it is essentially a sort of exception — any attempt to use it is an error. |
||
<lang haskell>undefined -- undefined value provided by the standard library |
<lang haskell>undefined -- undefined value provided by the standard library |
||
Line 513: | Line 513: | ||
if ![info exists arr(nullval)] ... |
if ![info exists arr(nullval)] ... |
||
if ![dict exists $dic nullval] ...</lang> |
if ![dict exists $dic nullval] ...</lang> |
||
You can algo use this condition inside an if statement to check if the variable $value is set or not: |
|||
<lang Tcl>[expr {([string compare "$value[puts \"\"]" ""]==1)}]</lang> |
|||
I think this is the better way to achieve it. In this case, if $value is set, returns true, or else returns false. |
|||
{{omit from|TI-83 BASIC}} {{omit from|TI-89 BASIC}} <!-- Does not have a null value. --> |
{{omit from|TI-83 BASIC}} {{omit from|TI-89 BASIC}} <!-- Does not have a null value. --> |