From: Stefan Kaes Date: 2005-11-23T01:04:35+09:00 Subject: Re: semenatics of if/unless/while statement modifiers David A. Black wrote: > 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. > All appreciated. Still you can't decide syntactically whether the = sign was put ther on purpose. So better change the warning text into "maybe". Only a suggestion, of course. -- stefan