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.

Source

Summary

left < right

Returns true if left is less than right

left <= right

Returns true if left is less than or equal to right

left > right

Returns true if left is more than right

left >= right

Returns true if left is more than or equal to right

__using__(opts)

Imports the StrictComparison macros into the current scope, and excludes their respective versions from Kernel

Macros

left < right

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
Source
left <= right

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
Source
left > right

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
Source
left >= right

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
Source
__using__(opts)

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.

Source