From: botp Date: 2008-06-17T23:35:37+09:00 Subject: Re: print(true and true) #=> the parenthesis issue On Tue, Jun 17, 2008 at 10:07 PM, Dave Bass wrote: > I've always used "&&" rather than "and". I know the two operators have > different precedences. The "&&" version comes naturally to me, thanks to > a C background. hacker :) > Can someone give non-contrived examples where "and" works nicely but > "&&" doesn't? I.e. what is the reason for including "and" in the > language, as it seems redundant to me. (The Pickaxe says "just to make > life interesting".) 1 reads better in english. i also would assume you do not like "or" ;) 2 handy for control flow otoh && is handy for value manipulation, eg, :001:0> x= true and false => false :002:0> x => true :003:0> x= true && false => false :004:0> x => false irb(main):005:0> x= (true and false) => false irb(main):006:0> x => false "and" and "or" comes natural (look i'm already using them :) w their low precedence in ruby, so you do not have to put a lot of parens when linking compound logical expressions. Sadly, there are special cases that the opposite (ie parens are mandatory) may be true (bug or not). Also, "and/or" names suggest their use and i do not even have to dig the manuals nor think hard just to get their meaning... kind regards -botp