Hello, After working with Elixir for some time I have found myself repeating some patterns when dealing with maps.
One pattern I see repeated constantly in different apps developed by myself or others is adding values to a map conditionally or returning the map unchanged. This comes in different flavors: [image: Screenshot 2024-12-06 at 11.13.23 AM.png] or [image: Screenshot 2024-12-06 at 11.14.32 AM.png] When this pattern gets used enough in an app, it's normal to see it abstracted in a MapUtils module that updates the map conditionally if a condition is met or returns the map unchanged otherwise. My proposal is to include Map.put_if/4 which would abstract the condition check and return the map unchanged if the condition is not met: [image: Screenshot 2024-12-06 at 11.17.21 AM.png] Enhancing the API by doing this will result in less code and more readable solutions. Thanks for reading! -- 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 visit https://groups.google.com/d/msgid/elixir-lang-core/ed7da716-b9f5-4f64-a77d-d32696326b9en%40googlegroups.com.