Checking if there's matching function clause before calling function

Is there a way in Elixir / Erlang, having a function reference and a set of argument, to figure out if a function can be called with these arguments or will it not match (and thus raise FunctionClauseError) ?

I am currently “solving” the same problem by wrapping the function call in try / rescue clause, but I think it’d be cleaner if I run just the guards / argument pattern matching on the function without actually calling it to figure out if there’s a match.

3 Likes