Null object: Difference between revisions

Content added Content deleted
No edit summary
(+Icon+Unicon)
Line 207:
Nothing -> "It's Nothing. Or null, whatever."
Just v -> "It's not Nothing; it is " ++ show v ++ "."</lang>
 
== Icon and Unicon ==
Icon/Unicon have a [[Icon%2BUnicon/Intro#null|null value/datatype]]. It isn't possible to undefine a variable.
 
==={{header|Icon}}===
<lang Icon>procedure main()
nulltest("a",a) # unassigned variables are null by default
nulltest("b",b := &null) # explicit assignment is possible
nulltest("c",c := "anything")
nulltest("c",c := &null) # varibables can't be undefined
end
 
procedure nulltest(name,var)
return write(name, if /var then " is" else " is not"," null.")
end</lang>
==={{header|Unicon}}===
This Icon solution works in Unicon.
 
=={{header|Io}}==