In this case:
% print/1: Prints out the integers between 1 and N print(0) -> io:format("~w~n", [0]); print(N) when is_integer(N) -> io:format("~w~n", [N]), print(N - 1).
If the user enters a non-integer, this happens:
11> effects:print('alfalfa'). ** exception error: no function clause matching effects:print(alfalfa)
About philosophy: Should I correct my program in such a way as to “catch all” types of input?
% print/1: Prints out the integers between 1 and N print(0) -> io:format("~w~n", [0]); print(N) when is_integer(N) -> io:format("~w~n", [N]), print(N - 1). % Last Line added: print(_Other) -> false.
I am new to erlang. Is there any agreement on this?
Thanks!
source share