Null object: Difference between revisions
Content added Content deleted
m ([Erlang] Format code clearly.) |
m ([Erlang] Format cleanup, improve wording.) |
||
Line 268: | Line 268: | ||
=={{header|Erlang}}== |
=={{header|Erlang}}== |
||
Erlang does not have an |
Erlang does not have an null object. As an alternative, many applications tend to pick a convention for returning an empty condition and use that. |
||
Example alternatives: |
Example alternatives: |
||
# Something like <pre>{ok, 3}</pre> or <pre>{err, no_more}</pre> on error. |
# Something like <pre>{ok, 3} % normal case</pre> or <pre>{err, no_more} % error case</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'''* |
||
## |
## '''undef''' |
||
## |
## '''null''' |
||
## |
## '''nil''' |
||
## |
## '''none''' |
||
'''undefined''' 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. |