Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Elixir warning: default arguments are never used

Tags:

elixir

I have the following Elixir function:

defp prod(a, b\\0) do
    a*b
end

On compiling, I get the warning:

warning: default arguments in prod/2 are never used

Why does it think the default value won't be used?

Edit: here's the gist, if you want to take a look at the whole thing https://gist.github.com/findjashua/2ed4204247d76849eb81

like image 730
tldr Avatar asked May 10 '14 02:05

tldr


1 Answers

It will warn you that the default arguments aren't used if you never call prod with a single argument in that module. I'm assuming somewhere you are calling prod with prod(someA, someB), but never prod(someA).

like image 122
bitwalker Avatar answered Oct 27 '22 03:10

bitwalker