Question

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

Was it helpful?

Solution

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).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top