[erlang-questions] catch
ok@REDACTED
ok@REDACTED
Wed Mar 2 00:37:47 CET 2011
> I have this escript to create a list of output:
>
> main([String]) ->
> case length(String) of
> 0 -> io:format("~nDid you forget the number?~n~n");
> _ ->
...
Just as a matter of curiosity, why not write
main([String]) ->
case String
of [] -> ...
; _ -> ...
end.
or even
main([""]) -> ...;
main([String]) -> ...
Also, why are you calling list_to_integer/1 twice?
case catch list_to_integer(String)
of {'EXIT',{badarg,_}} -> ...
; I -> ...
end
You did *try* typing
1> catch list_to_integer("fred").
2> catch list_to_integer("100").
didn't you?
More information about the erlang-questions
mailing list