"Rasputin" <one / nowhere.net> 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

?

> Most novice programmers would want to use that.

I beg to differ: the *only* reasonable usage of assignment in conditionals
is with "while" and "until", i.e. looping constructs, like in:

while ( line = gets )
  line.chomp!
  # do something with current line
end

Assignment in "if" and "unless" is totally superfluous.  It obfuscates code
and is not needed at all.  Every "if ( x = expression )" can be converted to

x = expression
if x
....

which is *much* clearer and cleaner IMHO.  Alternatively you can do this in
some cases:

x = expression and puts "yes"

> Ruby is not Python.

True.

> I'm just glad that I can turn them off. They just get more and more
> annoying with each incrementing version.

You should not turn them off but rather change the style of coding.  I can't
even tell when I saw that waning last time (other than for some experiments
for this thread).  And I don't have these warnings switched off.

Kind regards

    robert