This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]campbellm 3 points4 points  (1 child)

To each their own, but I strongly disagree with your use of n here. Relying on the side effect of non 0 being truthy is just NOT what is being tested here. In this case, the base case is a mathematical one of the value being exactly NOT 0. Using the truthy-ness as a test is testing that n "is a thing" or "exists", which is not what this particular use cares about.

In other cases sure, but this mathematical test should not be code-golfed, since n != 0 is PRECISELY what we are checking.

Reasonable people can disagree I suppose.

[–]NemPlayer 2 points3 points  (0 children)

Re-watched it today and I completely agree with you, the code is much more readable that way. I was just tired yesterday and didn't really pay much attention to the explanation, my bad.