I'm learning Elixir and am having trouble with a concept. Consider the following code:
iex(3)> case 1 do
...(3)> x -> "x exists"
...(3)> _ -> "something exists"
...(3)> end
"x exists"
iex(4)> x
** (CompileError) iex:4: undefined function x/0
The variable x
isn't bound to anything yet, then how does the first case
expression match? I thought it might be because Elixir is different from Erlang when it comes to assignment and so perhaps x
gets bound in the process, but the command #4 shows that x
isn't bound.