Null object: Difference between revisions

Content deleted Content added
Objeck (talk | contribs)
Line 439: Line 439:


Confusingly, there is also <code>NSNull</code>, a singleton class with one value, <code>[NSNull null]</code>, used as a dummy object to represent the lack of a useful object. This is needed in collections like arrays and dictionaries, etc., because they do not allow <code>nil</code> elements, so if you want to represent some "empty" slots in the array you would use this.
Confusingly, there is also <code>NSNull</code>, a singleton class with one value, <code>[NSNull null]</code>, used as a dummy object to represent the lack of a useful object. This is needed in collections like arrays and dictionaries, etc., because they do not allow <code>nil</code> elements, so if you want to represent some "empty" slots in the array you would use this.

=={{header|Objeck}}==
In Objeck, "Nil" is a value of every reference type.
<lang Objeck>
# here "object" is a reference
if(object = Nil) {
"object is null"->PrintLine();
}
</lang>



=={{header|OCaml}}==
=={{header|OCaml}}==