From: Rasputin Date: 2004-06-14T02:03:38+09:00 Subject: Re: assignment in conditional warning On Sat, 12 Jun 2004 16:36:27 +0200, Robert Klemme wrote: > > "Rasputin" schrieb im Newsbeitrag > news:pan.2004.06.11.20.50.29.369372@nowhere.net... >> Why in the world is there a warning, *even with brackets*, for assignments >> in conditionals. > > There are not always warnings; it seems, it's only warned if the right side > is a literal (i.e. a string or a number). This is reasonable because it is > likely that a comparison was meant. After all, what do you gain by doing > > if ( x = 10 ) > end > > over > > if ( 10 ) > end > > ? Actually, I don't think(not sure about this though) that Ruby actually knows, whether the number/string/whatever is in the literal(?) form, or if it's a return value from a function, beyond the parser level. Therefore, checking for it should be hard (or better yet, a waste of cycles). Personally, I think this warning should be allegated to the $VERBOSE == true level. (Those would be much easier to ignore) What I wanted to do was check if an array contained a certain value, and do something with it, or else. Simple matter. Just a mite obfusticated, if at all. So I think the stuff above made sense... (It was short and to the point anyway (i think...)) But this is just going to be a matter that will be discussed my many without anyone changing their minds (not really they won't). I mean should we go for short elegant code irritating-waste-of-spacers. Ha.