Created
October 23, 2015 03:55
-
-
Save killme2008/54381ae5f1bb2642d0cf to your computer and use it in GitHub Desktop.
Elixir macro example
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 MyUnless do | |
defmacro unless(clause, then_clause, else_clause \\ nil) do | |
quote do | |
if !unquote(clause) do | |
unquote(then_clause) | |
else | |
unquote(else_clause) | |
end | |
end | |
end | |
end |
Author
killme2008
commented
Oct 23, 2015
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment