From: SonOfLilit Date: 2007-02-14T05:42:00+09:00 Subject: Re: quick newbie true/false/nil question ------=_Part_76355_6376091.1171399307990 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Like in C, assignment returns IIRC the result of the assignment, so: ( (a = 2+3) == 5 ) == true On 2/13/07, Jason Mayer wrote: > > On 2/13/07, Jeff wrote: > > > > > > > > On Feb 13, 2:24 pm, "Jason Mayer" wrote: > > > I ran across this line of code today, and it doesn't make sense to me. > > > > > > if ((klass = CommDispatcher.check_hash(path)) == nil) > > > > > > How would that value ever equal nil? I thought that if klass failed > to > > be > > > assigned to the value of CommDispatcher.check_hash(path) then the > value > > > would be false and if it was assigned to the value of > > > CommDispatcher.check_hash(path) it would be true.. How would it be > nil? > > > > > > Thanks! > > > > I'm not familiar with the CommDispatcher class, but it looks like > > klass will be assigned whatever the return value of check_hash() > > returns, whether that's nil or false or something else. > > > > Jeff > > > > Right... but isn't the assignment of the value 'nil' going to return true > since the assignment succeeded? I remember screwing up a program by > forgetting to put in the extra = sign once... my if blah = blah2 statement > always returned true because the assignment occurred. > ------=_Part_76355_6376091.1171399307990--