From: Matthew Kerwin Date: 2012-07-21T09:03:41+09:00 Subject: Re: unless if not == unless post_on_ruby_forum On 20 July 2012 19:10, Lars Haugseth wrote: > On 07/20/2012 06:17 AM, Matthew Kerwin wrote: >> >> [unless is] most useful for perl-esque one-liners: >> >> die unless it_worked > > > Personally I find the following much more readable: > > do_something or > raise SomethingFailedException Me too, usually. Sometimes it's the case that, for example, you've iterated through a large collection, performing actions on members and whatever, and then at the end you only want to proceed if certain conditions were met during iteration. Then, depending on how you track the conditions, `bail unless more_needs_to_be_done` can be appropriate. It always depends on the situation, and where you want to trade off readability and maintainability (and, sometimes, efficiency.) -- Matthew Kerwin, B.Sc (CompSci) (Hons) http://matthew.kerwin.net.au/ ABN: 59-013-727-651 "You'll never find a programming language that frees you from the burden of clarifying your ideas." - xkcd