From: Martin Weber Date: 2004-01-14T03:09:58+09:00 Subject: Re: Warnings on assignments in conditionals? Oops, accidentally replied in private: On Wed, Jan 14, 2004 at 02:40:16AM +0900, David Heinemeier Hansson wrote: > I consider the following statements to be perfectly legit (although > perhaps slightly ambigious) and Ruby does obey, but throws this > mandating warning. Am I just being paranoid or is Ruby forcing a style > upon me :)? It is. The 'gcc' style.. an additional pair of parens around the expression et voila (funny enough, you need two) irb(main):001:0> if a = 1 then true else false end (irb):1: warning: found = in conditional, should be == => true irb(main):002:0> if (a=1) then true else false end (irb):2: warning: found = in conditional, should be == => true irb(main):003:0> if ((a=1)) then true else false end => true Regards, -Martin ..to which David replied: > >It is. The 'gcc' style.. an additional pair of parens around the > >expression et voila (funny enough, you need two) > > Pretty interesting. Anyone has the full story on why? > > / David Sorry. -Martin