From: "Ara.T.Howard" Date: 2004-01-14T05:06:42+09:00 Subject: Re: Warnings on assignments in conditionals? On Wed, 14 Jan 2004, David Heinemeier Hansson wrote: > Date: Wed, 14 Jan 2004 02:40:16 +0900 > From: David Heinemeier Hansson > Newsgroups: comp.lang.ruby > Subject: Warnings on assignments in conditionals? > > 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 :)? > > irb(main):008:0> if a = 1 then true else false end irb(main):008:0> if((a = 1)) then true else false end > (irb):8: warning: found = in conditional, should be == > => true > irb(main):009:0> a > => 1 > > irb(main):010:0> if a = nil then true else false end irb(main):010:0> if((a = nil)) then true else false end > (irb):10: warning: found = in conditional, should be == > => false > irb(main):011:0> a > => nil > -- > David Heinemeier Hansson. > http://www.loudthinking.com/ -- Broadcasting Brain -a -- ATTN: please update your address books with address below! =============================================================================== | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328 | STP :: http://www.ngdc.noaa.gov/stp/ | NGDC :: http://www.ngdc.noaa.gov/ | NESDIS :: http://www.nesdis.noaa.gov/ | NOAA :: http://www.noaa.gov/ | US DOC :: http://www.commerce.gov/ | | The difference between art and science is that science is what we | understand well enough to explain to a computer. | Art is everything else. | -- Donald Knuth, "Discover" | | /bin/sh -c 'for l in ruby perl;do $l -e "print \"\x3a\x2d\x29\x0a\"";done' ===============================================================================