View Source Patch.Apply (patch v0.14.0)

Utility module to assist with applying functions.

Link to this section Summary

Functions

Safe application of an anonymous function.

Link to this section Functions

Link to this function

safe(function, arguments)

View Source
@spec safe(function :: function(), arguments :: [term()]) :: {:ok, term()} | :error

Safe application of an anonymous function.

This is just like apply/2 but if the the anonymous function is unable to handle the call (raising either BadArityError or FunctionClauseError) then the :error atom is returned.

If the function evaluates successfully its reply is returned wrapped in an {:ok, result} tuple.