Why
foo(X) -> foo1(X).
foo1(bar) -> void; foo1(_Else) -> undefined.
rather than just
foo(bar) -> void; foo (_Else) -> undefined.
?
foo(X) -> foo1(X).
foo1(bar) -> void; foo1(_Else) -> undefined.
rather than just
foo(bar) -> void; foo (_Else) -> undefined.
?
Also the _Else part I would just make it into foo(_) -> undefined.
It depends.
Sometimes you want to crash when handed an unexpected value.
Sometimes you expect that you'll be handed unexpected values and need to either fail more gracefully, print a warning and then fail, or warn and keep going, or whatever.
Erlang gives you a bunch of tools, and they all have their place. [0] :)
[0] With the possible exception of the if statement... which is of questionable utility.