Skip to content

Instantly share code, notes, and snippets.

@mutablestate
Created April 15, 2015 09:03
Show Gist options
  • Save mutablestate/f0f091926e7c4a7dff2a to your computer and use it in GitHub Desktop.
Save mutablestate/f0f091926e7c4a7dff2a to your computer and use it in GitHub Desktop.
What if I never use pipe? Example 1 from blog post Pipe your way to readable and maintainable Elixir code
# setup
user = %{name: “Foo”}
new_name = %{name: “bar”}
# without pipe
updated_user = Map.put(user, :name, new_name)
validate_user = validate(updated_user)
# etc…
# with pipe
user
|> Map.put(:name, new_name)
|> validate
# etc..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment