Re:Pipelining might be my favorite programming language feature
by smallerize on Monday April 21, 2025 @08:27PM
(#43757928)
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-5e3...
Instead of:
```
fetch_data()
|> (fn
end).()|> String.upcase()
```
Something like this:
```
fetch_data()
|>? {:ok, val, _meta} -> val
|>? :error -> "default value"
|> String.upcase()
```