From: Gavin Sinclair Date: 2002-10-30T15:29:35+09:00 Subject: Re: "multiple assignment in conditional" From: "Bulat Ziganshin" > > 1.7.3: > GS> a, b = foo and puts a > syntax error > GS> (a, b = foo) and puts a > works ok and prints 4 That's good news. Thanks for the tip. > 1.6.7 produces the same result as your 1.6.5. i think that problem is > what "and" needs ONE value in first argument and your multiple > assihnment supports TWO values :) That's what I don't get. It gets one value, not two: a, b = 1, 2 # -> [1,2] "and" should be able to deal with an array. I'm surprised that a, b = foo and puts a doesn't work in 1.7, because, as I said, "=" binds more tightly than "and", so to my mind, that LOC should be exactly equivalent to (a, b = foo) and puts a Can anyone explain why it isn't? > btw, what you exactly want? > > a,b=foo; a and puts a > or > a,b=foo; b and puts a > or > a,b=foo; a and b and puts a > > ? ;) I want a, b = foo and puts a ! Since foo always returns non-nil, I want the equivalent of a, b = foo; puts a It's really a matter of style. The actual line of code is like this: results, duplicates = @scraper.get_backend_ids(last_record) and LOG.info "Retrieved backend IDs: #{results.length} of them" Gavin