From: Mike Stok Date: 2002-06-08T05:56:41+09:00 Subject: Re: precedence of =, and, or In article <89539780CB9BD51182270002A5897DF602C6D375@hqempn04.agedwards.com>, Volkmann, Mark wrote: > This message is in MIME format. Since your mail reader does not understand > this format, some or all of this message may not be legible. > > ------_=_NextPart_001_01C20E62.08AFAD70 > Content-Type: text/plain; charset="iso-8859-1" > > I'm fairly new to Ruby. > I was surprised to read that > a = b or c > will assign b to a, then perform a logical or of a and c. > I expected the precedence of and/or to be higher than = so that it would > perform a logical or of b and c, then assign the result to a. > > Do people like it this way? > > I'm interested in the rationale behind this decision. You can use the higher precedence && and || operators e.g. irb(main):001:0> b, c = 1, 2 [1, 2] irb(main):002:0> a = b && c 2 irb(main):003:0> a 2 irb(main):004:0> a = b and c 2 irb(main):005:0> a 1 I find that having the choice is useful, and being an *old* C person && and || seem very natural to me. As I use Perl a lot as well as Ruby it seems "natural" to me too. Mike -- mike@stok.co.uk | The "`Stok' disclaimers" apply. http://www.stok.co.uk/~mike/ | GPG PGP Key 1024D/059913DA mike@exegenix.com | Fingerprint 0570 71CD 6790 7C28 3D60 http://www.exegenix.com/ | 75D2 9EC4 C1C0 0599 13DA