Skip to content

Instantly share code, notes, and snippets.

@mutablestate
Created April 15, 2015 09:09
Show Gist options
  • Save mutablestate/ac5e2176f5856f1718b4 to your computer and use it in GitHub Desktop.
Save mutablestate/ac5e2176f5856f1718b4 to your computer and use it in GitHub Desktop.
What if I only use pipe when my function expands to more than one transformation? Example 2 from blog post Pipe your way to readable and maintainable Elixir code
# setup
user = %{name: “Foo”}
new_name = %{name: “bar”}
# single transformation without pipe
Map.put(user, :name, new_name)
# single transformation with pipe
user |> Map.put(:name, new_name)
# expanding transformation with pipe
user
|> Map.put(:name, new_name)
|> validate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment