Last active
October 25, 2016 18:02
-
-
Save shankardevy/b1b84032e3a22e1863444b69453a4f0d to your computer and use it in GitHub Desktop.
Generating functions based on macro
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 LearnMacro do | |
defmacro gen_func(func_name, arguments, do: expression) do | |
quote do | |
def unquote(:"#{func_name}")(unquote_splicing(arguments)), do: unquote(expression) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment