Elixir Warning: Default Arguments Never Used

I have the following Elixir function:

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

When compiling, I get a warning:

warning: default arguments in prod/2 are never used

Why does he think the default will not be used?

Edit: here is the gist if you want to take a look at all this https://gist.github.com/findjashua/2ed4204247d76849eb81

+4
source share
1 answer

It will warn you that the default arguments are not used if you never call prodwith a single argument in this module. I assume that you are calling prod with help prod(someA, someB), but never prod(someA).

+10
source

Source: https://habr.com/ru/post/1539996/


All Articles