Skip to content

Instantly share code, notes, and snippets.

@dylan-chong
Last active October 16, 2017 20:40
Show Gist options
  • Save dylan-chong/fcca06ac9fb7fa7809447dd095d58399 to your computer and use it in GitHub Desktop.
Save dylan-chong/fcca06ac9fb7fa7809447dd095d58399 to your computer and use it in GitHub Desktop.
Elixir assign at end of pipe
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