Toggle comments hack

Hi all,

I discovered this by accident and thought that it`s worth sharing.
Using the "hack" described below, you can switch between two code parts, by deleting or adding only one comment.
Here`s an example:

/*
... code 1 <- this code is hidden
/*/
... code 2 <- this code is active
//*/

Now if we remove the first comment:

... code 1 <- this code is active
/*/
... code 2 <- this code is hidden
//*/

Hope it helps : )
1
2
3
#if 1
#else
#endif 
is cleaner.
^Yeah, but you'd have to change more than 1 line of code to toggle that (unless you had some sort of define).
eh? you change the 1 to 0 to toggle.

Instead of remove the /* just add an extra slash //*
+1 for the #if 0 / #if 1 approach.

The comment approach falls to pieces if you have block comments in the code you're trying to comment out.
eh? you change the 1 to 0 to toggle.


*cough* Yeah...I uh...knew that all along. >_>
Topic archived. No new replies allowed.