[erlang-questions] Guards syntax for multiple values
Florent Gallaire
fgallaire@REDACTED
Sat Mar 23 04:24:28 CET 2019
Hello everybody,
I'm not very experimented in Erlang but I read carefully books and
official documention.
It seems to me that the guards syntax is not as good as it should be,
i.e. too much verbose for multiple values.
do(val1) -> val1;
do(val2) -> val2;
do(val3) -> val3;
do(val4) -> val4;
do(val5) -> val5.
do(Val) when Val =:= val1; Val =:= val2; Val =:= val3; Val =:= val4;
Val =:= val5 -> Val.
It's boring and error prone to write.
Has a "in tuple" syntax already be considered ? Something like :
do(Val) when Val in {val1, val2, val3, val4, val5} -> Val.
Cheers
Florent
--
FLOSS Engineer & Lawyer
More information about the erlang-questions
mailing list