2 ms·
This is how I understand it: how: "reset values in the array with a loop" why: "reset values so they don't affect the behaviour of foo()" The first explains
by alpaca128 7y ago
This is how I understand it:
how: "reset values in the array with a loop"
why: "reset values so they don't affect the behaviour of foo()"
The first explains what happens in the code and how, which is not as important because it should be already obvious from the code itself. While the second one explains the reason this part of the code exists, why it's important, why it was written that way.
- mytailorisrich 7y agoWhat the code does is not always obvious without quite detailed analysis. In those cases a comment does help. In general, if I have to put some effort into a piece of code and I understand now only because I put that effort in then my future self won't immediately understand it in 6 months time (and right now I'm the only person to understand it immediately). In these cases, 'how' comments help. Commenting is mostly common sense, imho.