3 ms·
Reading the update to Enum.sort, I could see in my head how easy a change this would be in elixer. Supporting a different second parameter (a symbol rather tha
by tyre 7y ago
Reading the update to Enum.sort, I could see in my head how easy a change this would be in elixer.
Supporting a different second parameter (a symbol rather than a function) can be implemented with another function that pattern matches to :asc or :desc. They can each call the original function(s) too.
In many other languages you'd start `sort` with a conditional and that function would need to handle every case. Not here. Each function worries about itself and what it can handle.
There's a beauty and practicality that Elixir hits so well.