Hi -

On Wed, 23 Nov 2005, Stefan Kaes wrote:

> David A. Black wrote:
>
>> Hi --
>> 
>> I'm happy to be told "should be", as I would never write:
>>
>>   if a = 1
>>     b
>>   end
>> 
>> instead of
>>
>>   a = 1
>>   b
>> 
>> (I hope :-)
>> 
>> 
> But the two forms are not equivalent :-(
>
> Probably you meant to write
>
> a = 1
> if a
> b
> end
>
> or (shocking)
>
> a = 1; b if a;

Actually I meant what I wrote.  Since 1 is always true, there's no
point ever testing it for truth.  (I purposely chose an example where
you get the warning, which you don't if there's any point to the
test.)

Another example would be:

   if a = nil
     b
   end

which is the same as:

   a = nil

Except actually it isn't, quite since:

   if a = nil
     b = 1
   end
   p b

and

   a = nil
   p b

are not the same....


David

-- 
David A. Black
dblack / wobblini.net