[erlang-questions] Local namespaces in case/try

Richard Carlsson carlsson.richard@REDACTED
Tue Jul 10 11:02:29 CEST 2012


On 07/10/2012 10:43 AM, Dmitry Groshev wrote:
> case do_something() of
>      {ok, Result} -> Result;
>      {error, Error} -> Error
> end,
> case do_another() of
>      {ok, Result} -> Result;
>      {error, Error} -> Error
> end,
>
> Result and Error are bound in first case and we will probably have a
> match failure in second one. Compiler warns about this, but it's still
> very unwieldy to fix it with names like Error1, Error2, etc.

Take it as a sign that you should break out those case expressions into 
separate functions, or restructure the code in some other way.

     /Richard



More information about the erlang-questions mailing list