Specix in Elixir - annotations, you cannot really interact with them from your code without repeating part of them. Therefore, you can write:
def operator(%Operator{operator: op}) when op in [:or, :and, :add, :mul, nil] do ... end
Or alternatively:
@ops [:or, :and, :add, :mul, nil] def operator(%Operator{operator: op}) when op in @ops do ... end
JosΓ© valim
source share