View Source Patch.Apply (patch v0.15.0)

Utility module to assist with applying functions.

Summary

Functions

Safe application of an anonymous function.

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.