From: akendo@...3.rim.or.jp Date: 1999-03-10T10:45:09+09:00 Subject: [ruby-list:12697] Re: operater bind order ? ruby 初心者の遠藤といいます。このたぐいのパズルものが好きな ので、初めて投稿させていただきます。 マニュアルの演算子の優先順位をみると、and と or は、優先順位が 同じなのに対して、&& は || より優先順位が高くなっています。 したがって、最初の式は、(not a or b) and ... と解釈されるのに 対し、3番目の式は、not a || (b and ... と解釈されるようです。 perl でちょっと試したら、and の方が優先されてるようで。 On Wed, 10 Mar 1999 08:46:47 +0900 "Kikutani, Makoto" wrote: > a = nil > b = nil > c = nil > d = 1 > n = 0 > > if not a or > b and n == 1 and not c and d > 0 > print "1) yup\n" > end > > if not a or > (b and n == 1 and not c and d > 0) > print "2) yup\n" > end > > if not a || > b && n == 1 && !c && d > 0 > print "3) yup\n" > end > > の結果が > > 2) yup > 3) yup > > になる理由がわからないのですが。