Skip to content

Instantly share code, notes, and snippets.

@Andy-Richards
Created October 10, 2013 10:31
Show Gist options
  • Save Andy-Richards/6916317 to your computer and use it in GitHub Desktop.
Save Andy-Richards/6916317 to your computer and use it in GitHub Desktop.
both statetements error with ....expected var!(v) to expand to an existing variable or be a part of a match
% from my unit tests
foo = 10
assert 10 == my_macro(:foo)
assert 10 == my_macro("foo")
% macro
defmacro my_macro(some_var) do
quote do
v = unquote(some_var)
if is_atom(v), do: var!(v)
if is_binary(v), do: var!(binary_to_atom(v))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment