Null object: Difference between revisions

Content added Content deleted
m ([Erlang] Fix atom list.)
m ([Erlang] Format code clearly.)
Line 271: Line 271:


Example alternatives:
Example alternatives:
# Something like {ok, 3} or {err, no_more} on error.
# Something like <pre>{ok, 3}</pre> or <pre>{err, no_more}</pre> on error.
# Don't ever allow an undefined return value, and throw an exception instead.
# Don't ever allow an undefined return value, and throw an exception instead.
# Return an atom:
# Return an atom:
## undefined*
## <pre>undefined</pre>*
## undef
## <pre>undef</pre>
## null
## <pre>null</pre>
## nil
## <pre>nil</pre>
## none
## <pre>none</pre>


* Often used by records as an initial value and the stdlib module.
<pre>undefined</pre> is often used by records as an initial value and the stdlib module.


Atoms are erlang's user-defined constants that always evaluates to is itself. It is also equal to no other value else but itself.
Atoms are erlang's user-defined constants that always evaluates to is itself. It is also equal to no other value else but itself.