Null object
As in standard C, Zen C has the concept of a null pointer and represents it with the NULL macro which generally evaluates to: (void*)0. Consequently, it can be cast (or implicitly converted) to a pointer of any other type and is treated as 'false' when used in boolean expressions.
fn main() {
let object = (void*)0;
if object == NULL {
println "object is null";
}
if !object {
println "that's right!";
}
}
Output:
object is null
that's right!
Attribution: This is a community solution for the Rosetta Code task Null object in Zen C.
This article uses material from the Rosetta Code article Null object, which is released under the GNU Free Documentation License 1.3. A list of the original authors can be found in the page history.