[erlang-questions] Illegal Guard?

Joe Armstrong erlang@REDACTED
Sun Feb 7 15:36:48 CET 2016


Why use a guard at all?

1> F = fun(5)->five; (_)->not_five end.

#Fun<erl_eval.6.54118792>

2> F(5).

five

3> F(6).

not_five

Cheers

/Joe

On Fri, Feb 5, 2016 at 1:40 PM, Theepan <vasdeveloper@REDACTED> wrote:
> Team - Any idea?
>
>
> 60>
>
> 60>
>
> 60> is_integer(A = 5).
>
> true
>
> 61>
>
> 61> fun () when is_integer(A = 5) -> ok end.
>
> * 2: illegal guard expression
>
> 62>
>
> 62>
>
> 62>
>
> 62> fun () when is_integer(5) -> ok end.
>
> #Fun<erl_eval.20.54118792>
>
> 63>
>
> 63>
>
> 63> fun (A = 5) when is_integer(A) -> ok end.
>
> #Fun<erl_eval.6.54118792>
>
> 64>
>
> 64>
>
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>



More information about the erlang-questions mailing list