Last active
October 16, 2017 20:40
-
-
Save dylan-chong/fcca06ac9fb7fa7809447dd095d58399 to your computer and use it in GitHub Desktop.
Elixir assign at end of pipe
This file contains 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
defmodule AssignPipe do | |
# Source: https://groups.google.com/forum/#!topic/elixir-lang-core/SJUgN5enNhc | |
defmacro value ~> var do | |
{:=, [line: 1], [var, value]} | |
end | |
end | |
defmodule Test do | |
import AssignPipe | |
def test() do | |
3 | |
|> Kernel.+(1) | |
|> Kernel.+(2) | |
~> r | |
r + 1 | |
end | |
end | |
Test.test | |
# => 7 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment