Same Functions Should Be Grouped Together
A favorite feature of Elixir is the function clauses that can be defined in multiple ways with pattern matching. I've always grouped same-named function clauses together. It seems like good form and it's what I see everyone else doing. It also makes for readable, maintainable code.
This is more than just personal preference though. It is the correct, idiomatic way to organize your Elixir function clauses. The compiler will let you know if anything gets out of place.
Consider the following snippet of code:
It is syntactically correct, so it will compile. However, the compiler will emit a warning like the following:
Last updated