Map.keys convert to string

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 Like