Re:Using “and” and “or” in Ruby
by sabat on Monday August 02, 2010 @01:12PM
(#1568221)
The logic for and/or vs. &&/|| is borrowed directly from Perl. It makes sense once you use them for a bit.
[ Parent
| on HN ]
Maybe I'm not good at the context-switching between parsing things as operators versus as English, but I find them confusing in Perl except in some very simple idiomatic cases, where they're fine because I read them as boilerplate. The common do_thing or die "error" idiom is perfectly readable, but anything more complex and I start explicitly reasoning about short-circuit semantics.
It's possible I have that reaction due to the strong negative consensus about using short-circuiting as control flow in C being hammered into my head at an early age, though.