CastLouis
Map.keys convert to string
Hi
i want to concat all the keys, from a map into one string separatly by comma, i was doing this:
> names = claims
> |> Map.keys
> |> Enum.each(fn (x)-> names <> x end)
Most Liked Responses
Qqwy
TypeCheck Core Team
Rather than Enum.each, you will want to use Enum.join.
Example:
data = %{"foo" => 1, "bar" => 2, "baz" => 0}
data |> Map.keys |> Enum.join(",")
For more general iterations where you are accumulating results, using Enum.each is usually not what you want, but instead, Enum.reduce.
1
smpallen99
Just a quick note about Enum.each. Its really only used for working with code that has side effects. It always returns :ok, not anything from the result of the passed fn.
1
Popular in Discussions
I recently came across the javascript library htmx. It reminded me a lot of liveview so I thought the community here might be interested....
New
Hello everyone :wave:
Today I am very excited to announce a project that I have been working on for almost 3 months now.
The project is...
New
Let me start by stating an assumption: Phoenix is a great approach to building REST APIs. There are many reasons for this, but I will ass...
New
It seems that the more I read, the more I find Elixir users speaking about all the ways that Elixir is not good for x, y, and z use cases...
New
Hey everone!
I created a prototype for my app using Nodejs for the api. But the framework I chose wasnt great (in general theresnt any g...
New
The reason that Rails is as popular as it is is because it’s very easy for relatively inexperienced developers to get a lot of work done....
New
Hi all,
I’ve seen a number of related threads in the past, but I’d still be very curious to hear an up-to-date opinion on this topic.
I...
New
Another point that Dave drives home in his course is that applications really are components, and you should treat them as such. Not as “...
New
What configs will make sense to put to runtime.exs?
–
A bit of how I configure apps:
I have generic configs in config/config.exs,
dev...
New
Here are the list of HTTP client libraries/wrappers, and some thoughts on HTTP client in general. I’d like to hear from others how they w...
New
Other popular topics
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
If I have a post route which an argument:
post /my_post_route/:my_param1, MyController.my_post_handler
How would get the post params ...
New
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
Hello all!
I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
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
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set?
Thanks.
New
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
New
Hi guys, i’m new in the Elixir world, and i have to say, that i love it!
i’m having some problem to understand anonymous functions with ...
New
Hi!
In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir?
Searched the docs for ip address and the web, no good results.
Thanks!
New
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine)
This is a plugin that adds support for Elixir to JetBrains IntelliJ...
New








