Take a look on the code, this is the macro definition
defmodule ControlFlow do
defmacro unless(expression, do: block) do
quote do
if !unquote(expression), do: unquote(block)
end
end
end
So when I write in the iex shell
iex(16)> ControlFlow.unless 2 == 5, do: "block entered"
I am expecting an ast as the result but I’ve got block entered
value. So when I write
iex(3)> quote do: if 5 == 5, do: "Hello Foo"
{:if, [context: Elixir, import: Kernel],
[{:==, [context: Elixir, import: Kernel], [5, 5]}, [do:"Hello Foo"]]}
in the shell, I’ve got an ast not the value.
Thanks