Guard Clause on Elixir Typespec
TIL that Elixir
has some type of guard clause for typespec:
defmodule TupleMaker do
@spec build(arg1, arg2) :: {arg1, arg2} when arg1: atom, arg2: integer | binary
def build(arg1, arg2), do: {arg1, arg2}
end
I still prefer to use @type
instead, but it's always useful to know alternatives.