Jump to content

Null object: Difference between revisions

→‎{{header|ooRexx}}: Extended the example and added output
(Added F# version)
(→‎{{header|ooRexx}}: Extended the example and added output)
Line 682:
</lang>
Uninitialized ooRexx variables do not evaluate to .nil, but rather the character string name of the variable (all uppercase). The var() built-in function allows variable validity to be tested:
<lang ooRexx>a=.array~of('A','B')
i=3
if \var("INPUT") then say "Variable INPUT is not assigned".
if a[i] == .nil then say "Item" i "of array A is missing"
</lang>
if \var("INPUT") then say "Variable INPUT is not assigned".
if \var("var") then say "Variable" var "is not assigned"</lang>
Output:
<pre>
Item 3 of array A is missing
Variable INPUT is not assigned
Variable VAR is not assigned
</langpre>
 
=={{header|Oz}}==
2,299

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.