Null object
Null object
You are encouraged to solve this task according to the task description, using any language you may know.
You are encouraged to solve this task according to the task description, using any language you may know.
Null (or nil) is the computer science concept of an undefined or unbound object. Some languages have an explicit way to access the null object, and some don't.
Show how to access null in your language by checking to see if an object is equivalent to the null object.
C
C's access to null is by way of a macro which simply evaluates to 0. <c>if(object == NULL){
printf("object is null");
}</c>
C++
C++'s access to null is (as in C) by way of a macro which simply evaluates to 0. <cpp>#include<stdio>
if(object == NULL){
cout << "object is null";
}</cpp>
Java
<java>if(object == null){
System.out.println("object is null");
}</java>
Ruby
if object == nil
puts "object is null"
end