Elixir: Set variable in if statement
In Elixir every statement returns the value. Instead of assigning variable in if
you can assign whole if
statement value into variable.
a = 0
a = if true do
1 + 1
else
a + 1
end
The warning is correct trying to prevent you from doing _ possibly dangerous_ thing. It is very well explained in the Elixir's 1.3 changelog.
Take a look at Deprecation of imperative assignment section, where it is explained (with example) here:
http://elixir-lang.org/blog/2016/06/21/elixir-v1-3-0-released/
Hope that helps!