|
|
|
|
|
by zapnuk
2072 days ago
|
|
Edit: My bad didn't recognize the parent comment was about Ruby, and that the code isn't elixir by a long way. Correct me if I'm wrong but I think there are 1 (and a half) other ways you could write it - that don't result in branching 1: def something(args) do
with {:ok, obj1} <- depencency1.call(args),
{:ok, obj2} <- dependency2.call(obj1),
{:ok, obj3} <- dependency2.call(obj2),
{:ok, obj4} <- dependency2.call(obj3),
{:ok, obj5} <- dependency2.call(obj4)
do
{:ok, obj5}
else
{:error, msg} -> {:error, msg}
end
end
1.5: Use a try/rescue block where you match {:ok, obj} and then catch Match errors. |
|