From: hakunin Date: 2008-06-17T23:58:56+09:00 Subject: Re: print(true and true) #=> the parenthesis issue On Jun 17, 10:37 am, Robert Klemme wrote: > On 17 Jun., 16:07, 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. > > I use "&&" in expressions (because of the precedence) and "and" when I > want to combine some "statements". > > > 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".) > > 16:35:55 OPSC_Gold_bas_dev_R1.2.2_prj$ ruby -ce 'x = some_work() && > puts x' > -e:1: syntax error, unexpected tIDENTIFIER, expecting kDO or '{' or > '(' > 16:36:09 OPSC_Gold_bas_dev_R1.2.2_prj$ ruby -ce 'x = some_work() and > puts x' > Syntax OK > > Does that give a clue? > > Kind regards > > robert The way 'and' differs from &&, and || differs from 'or' is pretty clear. Question is - what to do about this special case? It's completely logical when you follow interpreter logic, as it adheres to KISS (from interpreter perspective) however, it does not adhere to POLS from language user's view angle. One would say "you have to learn your interpreter", but I would argue that language is what we learn and interpreter is just a tool used by the language. Interpreter is there to interpret language, language is not there to adhere to the interpreter. Am I making sense?