Function Parameter Pattern Matching on multiple candidates?

spammy
Sat, 04 Apr 2026 21:32:17 +0000
Questions / Help

Is it possible to match multiple parameters to a single function body? So for:

def foo("a" = word) do
  word
end
def foo("b" = word) do
  word
end
def foo("c" = word) do
  "not a or b!"
end

have a single definition for the first two, so something like:

def foo("a" = word)
    foo("b" = word) do
  word
end
def foo("c" = word) do
  "not a or b!"
end

9 posts - 5 participants