title: What is the purpose of match operator (=) in elixir?
body: <p>I am reading Elixir's <a href="https://elixir-lang.org/getting-started/pattern-matching.html" rel="nofollow noreferrer">pattern matching</a> and I am a little confused on <code>=</code> operator being a match operator.</p>
  
  <p>The website says</p>
  
  <blockquote>
    <p>Elixir, the = operator is actually called the match operator.</p>
  </blockquote>
  
  <p>And it gives this example:</p>
  
  <pre><code>iex&gt; x = 1
  1
  iex&gt; x
  1
  iex&gt; 1 = x
  1
  iex&gt; 2 = x
  ** (MatchError) no match of right hand side value: 1
  </code></pre>
  
  <p>For some reason, I still don't understand what <code>1 = x</code> is doing. It returns <code>1</code> if I put the value of the variable I had just assigned to the left of <code>=</code> and throws error if the value is not the same. I can't really see how this is useful.</p>
  
  <p>What does it mean for <code>=</code> to be a <em>match operator</em>? Is it similar to <code>1 == x</code> (if so, why doesn't it return <code>true/false</code>)? When will I ever use match operator?</p>