[erlang-questions] Pipe Operator in Erlang?

Anthony Molinaro anthonym@REDACTED
Thu Jul 9 22:38:17 CEST 2015



> On Jul 9, 2015, at 1:03 PM, Serge Aleynikov <serge@REDACTED> wrote:
> 
> case {Ctrl, Char} of
>   {ctrl, _} ->
>     ignore;
>   {_, $\n} | {_, $\r} ->
>     end_of_line;
>   Other ->
>     Other
> end.
>     

This can be achieved now with a guard like so 

case {Ctrl, Char} of
  {ctrl, _} ->
    ignore;
  {_, C} where C =:= $\n; C =:= $\r ->
    end_of_line;
  Other ->
    Other
end

Granted it's not as compact...

-Anthony
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150709/f318f9e3/attachment.htm>


More information about the erlang-questions mailing list