Last active
October 24, 2020 12:03
-
-
Save karlosmid/98b079f7227b66ece0c0250a46668b21 to your computer and use it in GitHub Desktop.
example of using elixir macros
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 If do | |
defmacro if(clause, do: expression) do | |
quote do | |
if(unquote(clause) == :true, do: unquote(expression)) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment