I believe the most efficient way to do what you want is to reverse the order of arguments and call Map.merge/2 and Keyword.merge/2.
On Thu, Mar 4, 2021 at 5:29 PM Austin Ziegler <[email protected]> wrote: > This isn’t something I’ve needed often, but every time I have needed > it, I have to look up the docs of merge/3. Basically, I want to merge > two keyword lists or maps but only add new values (do not replace old > values). I know that this is just: > > ```elixir > Keyword.merge(left, right, fn _k, lv, _rv -> lv end) > ``` > > But I have to look it up in the docs every time; I think that adding > the new name here would be good UX. Alternatively, the accepted values > for `merge/3` could be changed to accept a conflict function or an > atom indicating the merge strategy. This is, IMO, worse UX because it > would also be incompatible with older versions (delaying its adoption > by libraries). > > -a > -- > Austin Ziegler • [email protected] • [email protected] > http://www.halostatue.ca/ • http://twitter.com/halostatue > > -- > 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/CAJ4ekQveKLuvrwyRwMCB-%2B_b6m%2BiZJgx%3D4EXfUs5AYe-Nb0Keg%40mail.gmail.com > . > -- 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/CAGnRm4K4mZzsX0%2BUQa2qwagEB1EXTOCS12QXaBH49-b42bZpbA%40mail.gmail.com.
