[LRUG] [Chat] IronRuby

Roland Swingler roland.swingler at gmail.com
Tue Jul 24 13:31:49 PDT 2007


One thing that hasn't been mentioned until now is the flexibility of
where you position the if/unless part of the conditional, and what
M.Fowler calls guard clauses. They aren't particularly appropriate in
the example given, but the ability to do:

def foo
  return kick_him if mystuff.forgot_mobile?
  # carry on with your method
end

brings the error handling code into one place before you get into the
real meat of what you are trying to do.

Not necessarily "better", but sometimes a useful alternative.

(P.S. one of the things I really like about Ruby is the fact you have
if, unless & two possible placements; having 4 options to do the same
thing really annoys some people, but I like the subtle differences in
what you are trying to communicate Re: the likelihood something will
happen).

Cheers,
Roland



More information about the Chat mailing list