From: Robert Klemme Date: 2009-04-29T15:00:02+09:00 Subject: Re: Can this code be more succinct On 29.04.2009 05:38, RichardOnRails wrote: > On Apr 28, 9:45 pm, RichardOnRails > wrote: >> Hi All, >> >> I like to use the following form for handling error situations: >> >> ( puts "ERROR: Long msg"; >> exit) if some_boolean _expression >> >> I want the multiple form because the error messages are often long and >> sometimes multi-line. >> >> Is there any way to improve it by getting rid of the parentheses? >> >> Thanks in advance, >> Richard > > Thank you both for your generous, expert advice. > > Here are two statements I now have in my app instead of my former, > convoluted and heavily parenthesizes statements: > > http://www.pastie.org/462055 Frankly, I find this bit still quite convoluted, especially because of the assignment in "unless". How about: arg = ARGV.shift || 'os' abort "ERROR:..." unless /\Aos\z/i =~ arg abort "ERROR: multiple..." unless ARGV.empty? Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/