I was reading a book on Elixir: Introducing Elixir.
On string compare it says that:
Elixir offers two options for comparing string equality, <
One example that comes to mind is floats - which use the same comparison functions as strings:
iex> 1 == 1 #true
iex> 1 == 1.0 #true
iex> 1 === 1 #true
iex> 1 === 1.0 #false
And for !==
iex> 1 != 2 #true
iex> 1 != 1.0 #false
iex> 1 !== 2 #true
iex> 1 !== 1.0 #true
It is worth noting that these functions use the following Erlang expressions:
Elixir | Erlang
== | ==
=== | =:=
!= | /=
!== | =/=
From the Erlang documentation:
When comparing an integer to a float, the term with the lesser precision is converted into the type of the other term, unless the operator is one of =:= or =/=. A float is more precise than an integer until all significant figures of the float are to the left of the decimal point. This happens when the float is larger/smaller than +/-9007199254740992.0. The conversion strategy is changed depending on the size of the float because otherwise comparison of large floats and integers would lose their transitivity.