Skip to content

Instantly share code, notes, and snippets.

@tonyc
Created March 17, 2019 15:29
Show Gist options
  • Save tonyc/3c6bd28bd25ece194a700ff6f9662ccb to your computer and use it in GitHub Desktop.
Save tonyc/3c6bd28bd25ece194a700ff6f9662ccb to your computer and use it in GitHub Desktop.
IO.inspect(quote do
defmodule QuoteTest do
def test(:foo), do: :foo
def test(:bar), do: :bar
def test(_), do: :anything
end
end)
### output
{:defmodule, [context: Elixir, import: Kernel],
[
{:__aliases__, [alias: false], [:QuoteTest]},
[
do: {:__block__, [],
[
{:def, [context: Elixir, import: Kernel],
[{:test, [context: Elixir], [:foo]}, [do: :foo]]},
{:def, [context: Elixir, import: Kernel],
[{:test, [context: Elixir], [:bar]}, [do: :bar]]},
{:def, [context: Elixir, import: Kernel],
[{:test, [context: Elixir], [{:_, [], Elixir}]}, [do: :anything]]}
]}
]
]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment