Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I like Yoda conditions not only because it protects against the missing "=", but also because often the constant is the shorter side, so reading

    if (42 == some_long_expression_here)
    {
        ...
    }
It is immediately clear that the rest of the line after the two equals signs must be an expression because the curly brace in the beginning of the next line. So folks don't have to bother that much about counting parens.


Well, you won't see 'magic values' in production code, or at least should minimize it




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: