Skip to content

Instantly share code, notes, and snippets.

@tonini
Last active April 26, 2016 11:21
Show Gist options
  • Select an option

  • Save tonini/4f0400808ad19bcd6c7e7a75b783a39e to your computer and use it in GitHub Desktop.

Select an option

Save tonini/4f0400808ad19bcd6c7e7a75b783a39e to your computer and use it in GitHub Desktop.
for.ex
for {k, v} <- keyword,
v = process_value(v),
into: %{} do
{v, k}
end
@gausby
Copy link
Copy Markdown

gausby commented Apr 26, 2016

This is another option. The parts of the list comprehension is aligned, and the do block is indented one level:

for {k, v} <- keyword,
    v = process_value(v),
    into: %{} do
  {v, k}
end

I am sure this would look better if there was more in the do-block.

@gausby
Copy link
Copy Markdown

gausby commented Apr 26, 2016

Perhaps this:

for {k, v} <- keyword,
  v = process_value(v),
  into: %{} do
    {v, k}
  end

Looks a bit odd to me though.

@tverlaan
Copy link
Copy Markdown

Not sure if you need another option but I thought it's also possible to do this:

for {k, v} <- keyword,
    v = process_value(v),
    into: %{}
do
  {v, k}
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment