Elixir: Using variables in case statement
<p>I've got this case statement which is giving an error 'variable constant1 is unused'. It seems to be ignoring the variables and returning the top line, so the variables obviously haven't got scope. If I replace the constant with a number 1 then it works. What is the best way of doing this in Elixir?</p>

<pre><code>defmodule Main 
do
    def constant1, do: 1
    def constant2, do: 1
    def constant3, do: 1

    x = 1
    y = 0
    z = 0

    {a, b, c, d} = 
        case {x, y, z} do
            {constant1, constant2, constant3} -&gt; {1, 2, 3, 4}
            {constant1, constant2, _} -&gt; {5, 6, 7, 8}
            {constant1, _, _} -&gt; {9, 10, 11, 12}
            {_, _, _} -&gt; {13, 14, 15, 16}
        end

    IO.inspect {a, b, c, d}
end
</code></pre>

<p>Here is the output:</p>

<pre><code>warning: variable constant1 is unused
  Untitled 9:15

{1, 2, 3, 4}
</code></pre>

<p>Changing the constants to variables also doesn't work.</p>