3 ms·
I am so proud of this (I'm sure others came up with it way before me, but I still came up with it all by myself!) //* normal path /*/ d
by customguy 18d ago
I am so proud of this (I'm sure others came up with it way before me, but I still came up with it all by myself!)
//*
normal path
/*/
debug path
//*/
take away the the first slash to toggle the debug zone ON!
- normie3000 18d agoIt's awesome in both senses! How readable has it become for you over time? Because on first glance and without syntax highlighting it's a head-scratcher.
- customguy 18d agoWith syntax highlighting I instantly know what it is :) But to be honest it's just for when I find myself toggling something a lot during development.. but still am too lazy to make a variable.
- penguin_booze 18d ago#if 0 // Normal path #else // Debug path #endif Only works with C and C++, though.
- elboru 18d agoC#: #if DEBUG Console.WriteLine("This only compiles and runs in Debug mode."); #else Console.WriteLine("This only compiles and runs in Release mode."); #endif
- pillmillipedes 18d agoI once took the time to figure these out for all the languages I use here's python: #''' normal path ''' debug path #''' when I comment out python code I do it with ''' ... #''' so I can uncomment it with 1 keystroke
- elboru 18d agoPretty cool, I love when I catch a coworker doing small tricks like this during pairing sessions.
- spartanatreyu 17d agoI always did it as: /**/ Debug code to toggle on and off /**/ Other debug code to toggle on and off /**/ And toggled by removing the last slash on one of the comment lines. Having two `*` characters worked better for syntax highlighting at the time. Then I learned about Ctrl/Cmd + / to toggle a line or region on and off. But I still use the old technique when code editors can't handle where comments are supposed to start and stop and commenting out too much or breaking the indentation, typically breaking around modern CSS's newer features or languages embedded within other languages.
- mitxela 17d ago/*/ is a comment "else", so you only need to change the first line to switch branches.
- mitxela 17d agoI also invented this by myself.