‹ BackHN Continuity

Thread

Ten lines of code that changed my world

148 points · 46 comments · dimonomid

  1. beanaroo · · focus · HN ↗
    Another fun one for a bit of shenanigans:

      #define true ((rand()&15)!=15)
    1. yencabulator · · focus · HN ↗

        #define false rand()==rand()
    2. drfloyd51 · · focus · HN ↗
      Cute.

      Back in the day, I looked down my nose at other young fledgling developers that would #define true 1. I knew only clarity and woe lived down that road.

          if(5-2 == true) ;
      
      As verbose as it was stupid.

      I felt superior because I knew that #define false 0 was the only Boolean keyword hack that would work.

          if (5-2 != false) ;
      
      Still verbose, and stupid, but at least it was correct.

      These days… I don’t feel as confident about anything as I did about those #defines.

Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.