The //* /*/ //*/ comment toggle trick (Example)
ccppjavascriptcommentsprogramming-tricks
Abstraction: Comment syntax trick to toggle code blocks without deleting them
Key points:
- Trick uses
//,//, and//*/to create a block that can be toggled by adding or removing a single/ - Works in C, C++, Java, JavaScript, and other languages supporting both
//and/ /comment styles - Limitation: fails in C/C++ if the toggled code itself contains block comments (
/ ... /), causing unintended behavior - Safer C/C++ alternative:
#if 1 ... #else ... #endifpreprocessor directive, which supports nested comments - Preprocessor approach requires changing only
1to0to toggle, with no embedded comment restrictions
Connections: Code Commenting ยท Preprocessor Directives
Source: https://coderwall.com/p/zbc2zw