‹ BackHN Continuity

Thread

Small programming tricks

681 points · 294 comments · signa11

  1. customguy · · focus · HN ↗
    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!
    1. penguin_booze · · focus · HN ↗

        #if 0
          // Normal path
        #else
          // Debug path
        #endif
      
      Only works with C and C++, though.
      1. elboru · · focus · HN ↗
        C#:

        #if DEBUG

            Console.WriteLine("This only compiles and runs in Debug mode.");
        
        #else

            Console.WriteLine("This only compiles and runs in Release mode.");
        
        #endif
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.