Easiest way to find the function that didn't match in the `with` statement

Relevant thread about with statements.

https://medium.com/very-big-things/towards-maintainable-elixir-the-anatomy-of-a-core-module-b7372009ca6d

Look at With chaining section of Sasa Juric article (I am unable to provide link to section as it has no hyperlink)

Kernel.SpecialForms — Elixir v1.16.0 - this is from elixir docs explain about else in with .

I am convinced with statements don’t need else most of the time. Are you trying to do some error recovery from else ?

if you have only one clause in else pattern matching error with {:error, e} and returning same, then its not needed. with will return error directly without need of else. I realised it very recently.

2 Likes