2 ms·
fetch_data() |> case do {:ok, val, _meta} -> val :error -> "default value" end You have the extra "case do...end" block but it's pretty close?
by smallerize 1y ago
fetch_data()
|> case do
{:ok, val, _meta} -> val
:error -> "default value"
end
You have the extra "case do...end" block but it's pretty close?
This is for sequential conditions. If you have nested conditions, check out a where block instead. https://dev.to/martinthenth/using-elixirs-with-statement-5e36#3-chained-functions-in-with-statements https://dev.to/martinthenth/using-elixirs-with-statement-5e3...
- manmal 1y agoThanks, that looks good!