> On Jun 22, 2022, at 04:37, Nganga Mburu <mburungan...@gmail.com> wrote: > > > We've used `map[key] || default_value`, or even `Map.get(map, key) || > default_value` before but I felt this being handled my `Map.get/3` would be > better. > > `Map.get(map, key, default_value)` looks better than `Map.get(map, key) || > default_value`
This assumes that `nil` isn’t a valid value. For your use-case it may be. For other cases, it may be a valid and important value. I know for a fact that this would break some production code we run and be a surprising result for us because it would not behave the way we expect for anything else, including JavaScript Map.get. -a -- 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 elixir-lang-core+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/AD835157-EA24-48F4-A4D0-5FD2DB89B20E%40gmail.com.