On Apr 9, 2005 12:08 AM, Glenn Smith <glenn.ruby / gmail.com> wrote:
> Interesting how everybody picks up on the 'unless this do this' or 'do
> this unless' code.  I also played with a number of styles for these.
> My thoughts were that I wanted to put 'what would happen usually'
> first, and 'what would happen if it failed' second.  ie.
> 
> 'do this but if it fails do that'
> 
> or
> 
> 'if !save then raise'
> 
> On the other hand I like the tidier English of 'raise unless save'.

You can have the best of both worlds with 'or'.

save or raise "Couldn't save!"

This only works if save always returns a true value for success and
false value for failure (which from your examples, it looks like it
does).

Jacob Fugal