As far as I understand how Elixir works, using Map makes the code DRYer, but it doesn't leverage Elixir and BEAM optimization process.
With @p1_wins_table[p1] Map is accessed during runtime, where def ("scissors"), do:... are optimized during compilation and there's no need to lookup for proper values in the Map on runtime. For the sake of this kata, this may seem irrelevant but may play a significant role in real-world use cases.
As far as I understand how Elixir works, using Map makes the code DRYer, but it doesn't leverage Elixir and BEAM optimization process.
With
@p1_wins_table[p1]
Map is accessed during runtime, wheredef ("scissors"), do:...
are optimized during compilation and there's no need to lookup for proper values in the Map on runtime. For the sake of this kata, this may seem irrelevant but may play a significant role in real-world use cases.More info: https://medium.com/@amuino/maps-vs-pattern-matching-in-elixir-e69b7bb11b5d