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

Those one line returns are particularly handy at the beginning of methods, to validate or process arguments and return immediately for simple cases.


Short circuiting is such a beautiful way of avoiding giant nested "if" mountains. I wish it was more widely used.


right but

    if condition { return } 
works well enough in other languages and shows actual condition (the important part) to programmer first. if that if and extra brackets is really too long Perl way is also option.

    condition || return




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

Search: