Quantcast
Channel: Variable assignment in Elixir - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Variable assignment in Elixir

$
0
0

I have a question about variable assignment in Elixir. In Erlang, this would raise a no match of right hand side value:

X = 4.X = 2.

However, it seems perfectly fine in Elixir to assign a value to a variable more than once. I am confused how pattern matching works in Elixir. How does Elixir differentiate between pattern matching and variable assignment? From what I understand, in Erlang, X is an unbound variable so it can be matched with anything, right? But once it is bound, pattern matching only works if it is the same value as X. So does Elixir not share the same concept of unbound variables as Erlang?


Viewing all articles
Browse latest Browse all 3

Trending Articles





<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>