Re:Read this post ‘unless’ you’re not a Ruby developer
by pmontra on Tuesday December 13, 2022 @06:55AM
(#33967671)
Those one line returns are particularly handy at the beginning of methods, to validate or process arguments and return immediately for simple cases.
[ Parent
| on HN ]
Re:Read this post ‘unless’ you’re not a Ruby developer
by hnzix on Tuesday December 13, 2022 @08:21AM
(#33968458)
Short circuiting is such a beautiful way of avoiding giant nested "if" mountains. I wish it was more widely used.
Re:Read this post ‘unless’ you’re not a Ruby developer
by ilyt on Tuesday December 13, 2022 @09:13AM
(#33969099)
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