air

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

lpil

Creator of Gleam

I find it quite understandable. I’ve always found slice hard to remember, even after many years of Ruby

lpil

lpil

Creator of Gleam

You also take a subset. Language is tricky :slight_smile:

gregvaughn

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.

Where Next?

Popular in Discussions Top

Other popular topics Top

marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
274 41454 115
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
boundedvariable
I am going through the kafka architecture. All the features what the kafka is providing are already in Erlang. I would like hear your opi...
New
Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 126226 1237
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

We're in Beta

About us Mission Statement