elixir-analyzer icon indicating copy to clipboard operation
elixir-analyzer copied to clipboard

Remote Control Car: Analyzer recommends a default argument for an arity zero function.

Open amazinglarry4tw opened this issue 9 months ago • 2 comments

If I'm reading this correctly, the analysis recommends that I "Use a default argument for defining the function new. despite the instructions asking for an arity/0 function.

Image Image

Unless this is recommending a default argument for the arity/1 function, it conflicts with the instructions of the exercise to have a default argument for a function that should take zero arguments. Maybe I'm wrong, though?

amazinglarry4tw avatar May 23 '25 19:05 amazinglarry4tw

I believe the default argument you are asked to use is for the nickname. If you use ‘def new(nickname \\ “none”)’ you will define both a function of arity 0 and arity 1, since the argument is optional. (Sorry for the poor formatting, on my phone)

jiegillet avatar May 24 '25 00:05 jiegillet

Ahhh yes, duh - that's definitely it. I'm still new on the Elixir journey, so that didn't even occur to me. Might be cool to enhance the analyzer to mention that but otherwise definitely seems to be user error on my part. Thanks for the explanation!

amazinglarry4tw avatar May 24 '25 01:05 amazinglarry4tw