From: "list. rb" Date: 2008-10-04T10:05:38+09:00 Subject: Re: Is Assignment in a Conditional an Idiom? ------=_Part_26732_6918392.1223082424157 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Fri, Oct 3, 2008 at 4:36 PM, David A. Black wrote: > Hi -- > > On Sat, 4 Oct 2008, List.rb wrote: > > I just figured ruby was looking at the value of a returned from the >> definition in the condition. The value of 'a' is still false after the >> second condition. >> > > Are you talking about this one? > > puts "Never reached" unless (a = nil) || (!a = a) > > It's a peculiar line of code, but it's entirely logical. The > expression !a = a has to mean !(a = a), because !a isn't an lvalue. > Since a is nil, the expression a = a (or x = a, etc.) evaluates to > nil. So you've basically got: > > unless nil || nil > > I might be misunderstanding the part you thought was questionable in > its logic. > > > > David > > -- > Rails training from David A. Black and Ruby Power and Light: > Intro to Ruby on Rails January 12-15 Fort Lauderdale, FL > Advancing with Rails January 19-22 Fort Lauderdale, FL * > * Co-taught with Patrick Ewing! > See http://www.rubypal.com for details and updates! > > It was late, sorry. I have no idea what I was thinking. ------=_Part_26732_6918392.1223082424157--