Last active
October 14, 2020 04:22
-
-
Save apboobalan/a42b82451dbc5b7fae6ca8616f02180a to your computer and use it in GitHub Desktop.
Curious case of 'in'. Add syntactic sugar while writing code.
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 Validator do | |
defmacro having({:in, _, [lhs, rhs]}) when lhs |> is_binary and rhs |> is_binary, | |
do: rhs |> String.contains?(lhs) | |
defmacro having({:in, _, [_lhs, _rhs]}), do: false | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment