On Nov 16, 2010, at 14:14 , Eric Christopherson wrote:

> I'm not sure I understand what you mean. Are you saying it's bad to do
> the *first* assignment to a variable inside a conditional? Or it's bad
> to assign inside a conditional in any case? I can understand the
> first, but I'm not sure how you would work around the second, unless
> you used a more functional style like
> 
> x = (n > 2 ? true : false)
> 
> or
> 
> x = (if n > 2; true; else false; end)

this is not an assignment inside a conditional. It is a conditional inside an 
assignment. And as Jeff pointed out, while just an example, it is a very 
contrived example (that hits one of my biggest pet peeves).

an assignment inside a conditional is

do_something(x) if x = logical_statement

or

if x = logical_statement then
  do_something(x)
else
  do_something_else
end

and whether you're coding in ruby, C/++, or whatever... it is almost always 
considered bad form. Avoid it not only for the reasons I mentioned before, but 
also to avoid the beat downs you'll get whenever you ask for our community's 
help. I cannot guarantee your safety otherwise.

_______________________________________________
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel

Reply via email to