StrictComparison
Strict numeric comparison.
In Elixir (and Erlang), all terms are comparable. While this is useful in many
situations, sometimes you want comparing anything but 2 numbers to be an error
(or, in the case of function clauses, not a match). Simply use this module and
Elixir’s comparator functions (<
, >
, <=
, and >=
) will only allow
numeric arguments within the current scope.
Summary
left < right | Returns |
left <= right | Returns |
left > right | Returns |
left >= right | Returns |
__using__(opts) | Imports the |
Macros
Returns true
if left is less than right.
Only numbers can be compared with each other.
Allowed in guard tests. Inlined by the compiler.
Examples
iex> 1 < 2
true
Returns true
if left is less than or equal to right.
All terms in Elixir can be compared with each other.
Allowed in guard tests. Inlined by the compiler.
Examples
iex> 1 <= 2
true
Returns true
if left is more than right.
Only numbers can be compared with each other.
Allowed in guard tests. Inlined by the compiler.
Examples
iex> 1 > 2
false
Returns true
if left is more than or equal to right.
Only numbers can be compared with each other.
Allowed in guard tests. Inlined by the compiler.
Examples
iex> 1 >= 2
false
Specs:
Imports the StrictComparison
macros into the current scope, and excludes
their respective versions from Kernel
.
Supports the option :only
which functions in the same manner as
Kernel.SpecialForms.import/2
, where only the specified macros will be
excluded/imported.