Pergunta

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

Foi útil?

Solução

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

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top