From: Justin Collins Date: 2008-03-11T08:40:00+09:00 Subject: Re: and statement Subbu wrote: > On Mar 4, 1:18 pm, yermej wrote: > >> On Mar 4, 8:23 am, Lionel Bouton >> wrote: >> >> >> >> >>> 7stud -- wrote: >>> >>>> Subbu wrote: >>>> >>>>> Thank you so much. I looked up 'and' && operands in the PickAxe book >>>>> and this is what it says: >>>>> "The 'and' and && operators evaluate their first operand. If false, >>>>> the expression returns the value of the first operand; otherwise, the >>>>> expression returns the value of the second operand" >>>>> >>>> Which doesn't appear to be true. Look at this: >>>> >>>> result = (x=20) >>>> puts result #20 >>>> >>>> result = true and x=20 >>>> puts result #true >>>> >>> Precedence... >>> >>> result = (true and x = 20) >>> >> Or: >> >> result = true && x = 20 >> >> The precedence is the only difference between 'and' and '&&'. >> > > Does that mean = has higher precedence than 'and'? > > Yes. http://phrogz.net/ProgrammingRuby/language.html#table_18.4