3 ms·
> When making changes to a block of code or block of text, I frequently just comment out the code and rewrite it anew. This is the comment I came here for. (se
by dmuth 6y ago
> When making changes to a block of code or block of text, I frequently just comment out the code and rewrite it anew.
This is the comment I came here for. (see what I did there?)
I also sometimes keep multiple versions of the same line in comments, such as when I'm trying to a tricky regex work. For example, I might have code that looks like:
# x = regex1 # Original line
# x = regex2 # Doesn't work
# x = regex3 # Nope
# x = regex4 # Also nope
x = regex5 # Currently testing this
That gives me the way to see which approaches I've tried while solving the problem, and ensures I don't actually use the same exact regex twice.
When I get a working solution, I comment out all but the line that works and commit that.
- jonnycomputer 6y agoIn this case, keeping those in the commit might be worth it, if you come back and find that the regex wasn't right after all. That way you can make sure you (or others) don't repeat your mistakes. The comment could go in the commit message instead I guess, though I tend to keep those brief.