Created
July 12, 2018 03:08
-
-
Save ktravers/c81a006c9aff519314accdc7b546dda4 to your computer and use it in GitHub Desktop.
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
# Not recommended: macros | |
defmodule Account.Guards do | |
defmacro is_private(first_name, email) do | |
quote do | |
not(is_nil(unquote(first_name))) and | |
not(unquote(email) == unquote(first_name)) | |
end | |
end | |
end | |
# Recommended: defguard | |
defmodule Account.Guards do | |
defguard is_private(first_name, email) when not(is_nil(first_name)) and not(email == first_name) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment