
Ask HN: What's your simple but favourite coding trick? - zupzupzup
When I started programming, 5-6 months into it, I was introduced to a very interesting trick&#x2F;pattern by one of my mentors.<p>func(){<p><pre><code>    if() {

    } else {

    }
</code></pre>
}<p>can be beautifully converted to<p>func(){<p><pre><code>    if() {
    
     
        return; 
    }

    &#x2F;&#x2F; Write the else code here.
 </code></pre>
}<p>The reduced indentation gave a weird sense of relaxation. It was such a neat little trick.<p>What about you guys. Any common tricks which everyone can use.
======
catacombs
From your example, an even more concise way can be written using ternary
operations in any C-style language:

    
    
        int i = 10;
        bool is_10 = (i === 10) ? TRUE : FALSE;

