Last active
August 29, 2015 13:57
-
-
Save alco/9649919 to your computer and use it in GitHub Desktop.
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 M do | |
defp cases do | |
[quote do 1 -> 2 end, quote do 3 -> 4 end] | |
end | |
defmacrop make_case do | |
q = quote do | |
case var!(x) do | |
0 -> nil | |
unquote_splicing(cases) | |
end |> IO.inspect | |
end | |
q |> Macro.to_string |> IO.puts | |
q | |
end | |
def test(x) do | |
make_case | |
end | |
end | |
### Output ### | |
case(var!(x)) do | |
0 -> | |
nil | |
(1 -> 2) | |
(3 -> 4) | |
end |> IO.inspect() | |
** (CompileError) tes.ex:18: unhandled operator -> | |
(elixir) case.ex:18: Kernel.|>/2 | |
/Users/alco/Dropbox/home/projects/elixir/numspell/tes.ex:18: M.test/1 | |
/Users/alco/Dropbox/home/projects/elixir/numspell/tes.ex:18: M.make_case/0 | |
/Users/alco/Dropbox/home/projects/elixir/numspell/tes.ex:18: M.test/1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment