What is the difference between "===" and "==" in Elixir?

2

I would like to know the difference between == and === when making expressions and conditionals with elixir

    
asked by anonymous 17.02.2018 / 03:41

1 answer

3

Unlike most languages, === does not double-check equivalence and type. As in javascript:

> 1 === "1"
false
> 1 == "1"
true

In Elixir, the difference between == and === is that the latter is more stringent when comparing integers and floats:

iex> 1 == 1.0
true
iex> 1 === 1.0
false

You can use == in all conditions that do not use numbers since the difference between === and == affects comparison between numbers only.

I'll leave two sources here for a better understanding of the subject:

  

Documentation:    link
  Question on stackoverflow in English:    link

    
17.02.2018 / 03:41