Hi --

On Tue, 22 Nov 2005, Stefan Kaes wrote:

> David A. Black wrote:
>
>> What would you want to happen here?
>>
>>   def x
>>     puts "method x"
>>   end
>>
>>   x if x = 1   # method x
>>   puts x       # 1
>> 
> That's easy to answer: the same thing that would happen for
>
> def x
>   puts "method x"
> end
>
> if x = 1
>   x
> end
>
> puts x
>
> You could still use () to disambiguate between local x and method x.

Ugh.  Well, I normally would avoid the name clash anyway, but ugh :-)

> But I certainly don't want to get this message:
>
> warning: found = in conditional, should be ==
>
> This one would be better
>
> warning: found = in conditional, maybe you meant ==

Ruby is pretty selective about when it gives this warning.  You
probably really would never mean to conditionally assign any of the
things it warns about:

   if x = 1      # warning
   if x = "1"    # warning
   if x = 0 + 1  # no warning
   if x = true   # warning
   if x = true && true  # no warning

etc.


David

-- 
David A. Black
dblack / wobblini.net