How do I do the below, for example
A = atom_a,
case A of
atom_b or atom_c ->
%do something here;
atom a ->
%do something else!
end.
You can use guards:
A = 'atom_a',
case A of
B when B =:= 'atom_b'; B =:= 'atom_c' ->
%do something here;
'atom_a' ->
%do something else!
end.
Try the following:
case is_special_atom(A) of
true ->
%do something here;
false ->
%do something else!
end.
is_special_atom(atom_b) -> true;
is_special_atom(atom_c) -> true;
is_special_atom(_) -> false.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With