Every couple of months, we get a request for Enum.compact. So far, the main argument against it is that Enum.reject list, &is_nil/1 is sufficient.
When you compare the difference in a pipe, you can see a significant difference in readability. It really is a pervasive use case. list |> nil_or_result |> compact versus list |> nil_or_result |> reject(&isnil/1) One possible solution is for Enum.reject to take a default function as an argument. I suggest a default of fn(x) -> x end That would make the above example: list |> nil_or_result |> reject which reads just fine, I think. There is ample precedent for meaningful defaults in enum. is_nil/1 and &(&1) are meaningful defaults. Thoughts? -bt -- Bruce Tate President, RapidRed, LLC Phone: 512.772.4312 Fax: 512 857-0415 Author of Seven Languages in Seven Weeks, Deploying Rails Applications, >From Java to Ruby, Rails: Up and Running, Beyond Java, 6 others. -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAMp4_ii%3DMzw1UxQtWoRuYy%2Bej35dnGosvt7c2AMocPeXbgVCzQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
