Skip to content

Instantly share code, notes, and snippets.

@Andy-Richards
Created November 12, 2013 12:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Andy-Richards/7430199 to your computer and use it in GitHub Desktop.
Save Andy-Richards/7430199 to your computer and use it in GitHub Desktop.
defmodule MyMacro do
defmacro do_something(query) do
quote do
args = String.split(unquote(query))
fun = fn(arg) -> IO.inspect var!(unquote(binary_to_atom(arg))) end
Enum.each args, fun
end
end
end
defmodule Test do
require MyMacro
wibble = 123
wobble = abc
MyMacro.do_something("wibble wobble")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment