From: Rick DeNatale Date: 2008-03-30T21:16:32+09:00 Subject: Re: Boolean Operators On 3/29/08, Robert Klemme wrote: > I use "and" and "or" rather seldom mostly when chaining commands > as in > > foo = doit() and puts foo Keeping in mind that using && instead of and here has quite a different result, even after adjusting the syntax of the puts call: irb(main):001:0> a = 1 and puts "foo" foo => nil irb(main):002:0> a => 1 irb(main):003:0> a = 1 && puts "foo" SyntaxError: compile error (irb):3: syntax error, unexpected tSTRING_BEG, expecting kDO or '{' or '(' a = 1 && puts "foo" ^ from (irb):3 irb(main):004:0> a = 1 && puts("foo") foo => nil irb(main):005:0> a => nil I don't know that I've ever used 'and' since being bitten by the relative precedence of = and 'and' in a rails app I inherited and was extending. I also don't believe that I'd personally use a = 1 and puts "foo" rather than splitting it into two lines, perhaps replacing the and with a semi-colon or otherwise steppng back and micro-refactoring the code to make it clearer. But I could be wrong. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/