Created
April 15, 2015 09:09
-
-
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
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”} | |
# 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