Honestly, there's no magic involved, just a bit of logic. Let's say there's some code consisting of 3 blocks of lines:
[block 1]
[block 2]
[block 3]
If I want to comment one block, I could simply put /*, */ around it like this:
/*
[block 1]
*/
[block 2]
[block 3]
However, soon enough I figure I needed to comment block 2 for a while. Because I'm lazy, I try to type no more than needed, so it becomes this:
//*
[block 1]
/*/
[block 2]
*/
[block 3]
I'm almost happy now, but it seems I need to switch back to having block 1 commented again instead of block 2... Of course I can remove the added characters, or I can just add a few more:
/*/*
[block 1]
/*/
[block 2]
/*/
//*/
[block 3]
Now if I decide that I need to comment block 2 again, I only need to edit one character:
//*
[block 1]
/*/
[block 2]
/*/
//*/
[block 3]
And it's actually possible to chain these by using a /*/ between 2 blocks. If the block in front was commented, the next block won't be commented. If the block in front however was not commented, this block will be commented. And there you go, boolean logic with comments, it's almost magic.
No comments:
Post a Comment