air
Map.take is not a good name
Hi all! Just want to know if there is someone else thinking Map.take is not a very good name for function that returns subset of a map. It’s not an issue or something but I feel uncomfortable with that name. In ruby, for example, method with same functionality called slice. When I type Map.take([:a, :b]) I expect a list of values mapped to these keys. What do you think?
Most Liked
lpil
I find it quite understandable. I’ve always found slice hard to remember, even after many years of Ruby
lpil
You also take a subset. Language is tricky ![]()
gregvaughn
The name take seems very natural to me. What you describe there could be done with %{a: 1, b: 2, c: 3} |> Map.take([:b, :c]) |> Map.values() (provided ordering is not important).
However, I have wanted a Map.values/2 that has an extra parameter to name which keys’ values you want.







