Created
April 15, 2015 09:03
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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