3 ms·
Here's some real code from our work system (variable names have been changed): invoice_id |> Audit.get_entries() |> Enum.map(fn entry -> entr
by dnautics 5y ago
Here's some real code from our work system (variable names have been changed):
invoice_id
|> Audit.get_entries()
|> Enum.map(fn entry ->
entry.action
end)
|> Enum.map(fn action ->
to_string(action)
end)
|> Enum.join("\n")
Tell me you can write that as an "easier to understand" set of loops. Tell me that this code is "write-only" and that you don't immediately understand what is happening, without even knowing the language it's in.
- valzam 5y agoThe pipe operator really is elixirs secret sauce. The whole OTP platform amazing but web servers can live without it. But the developer ergonomics of the pipe operator for code that is to a large extent 1) accept input 2) parse input 3) transform input 4) store input Is just amazing
- patrick451 5y agoYes, I'll go ahead and say that. I have no idea what this does. It would be a lot clearer as loops.