Packages

Macros expanding into code that can be safely used in guard clauses.

Current section

Files

Jump to
guardsafe lib guardsafe.ex
Raw

lib/guardsafe.ex

defmodule Guardsafe do
@moduledoc """
Provides readability-enhancing macros that can safely be used in guard clauses.
"""
@doc """
Expands `divisible_by?(number, divisor)` into `rem(number, divisor) == 0`
"""
defmacro divisible_by?(number, divisor) do
quote do
rem(unquote(number), unquote(divisor)) == 0
end
end
end