From: YANAGAWA Kazuhisa Date: 2004-01-14T18:52:46+09:00 Subject: Re: Warnings on assignments in conditionals? In Message-Id: <7EC8AB04-45F2-11D8-A416-000A958E6254@loudthinking.com> David Heinemeier Hansson writes: > def apply_coupon(code) > if @coupon = Coupon.find_by_code(code) then true else false end > end > > I guess I'm questioning when, or even if, the parser should throw > warnings on something that it considers to be bad style. > ruby -wc -e 'if str = ""; end' -e:1: warning: found = in conditional, should be == Syntax OK > ruby -wc -e 'if str = gets; end' Syntax OK > ruby -v ruby 1.8.0 (2003-09-09) [i386-freebsd4] So I'm not sure but at least 1.8.0, only assigning a literal in a condition is warned for my understanding. That can be pointed out as a mistake on high probability, isn't it? -- kjana@dm4lab.to January 14, 2004 What can't be cured must be endured.