On Thu, 18 Jul 2002, ts wrote:

> >>>>> "H" == Hugh Sasse Staff Elec Eng <hgs / dmu.ac.uk> writes:
>
> H> That should be "and" rather than "or" for both to be done if error_flag
> H> ??
>
> pigeon% cat b.rb
> #!/usr/bin/ruby
> error_message = "error\n"
> error_flag = true
> print error_message and exit 1 if error_flag
> puts "after"
> print error_message or exit 1 if error_flag
> puts "after"
> pigeon%
>
> pigeon% b.rb
> error
> after
> error
> pigeon%
>

Hmmm. I always get tangled with these.  Bracketing things doesn't help
here (I tried it).  I'd have expected the or to "short circuit" after
the print succeeded..... Oh, but print returns Nil, is that it?  Hmmm.
I'm thinking in Shell I suppose!  Or Icon...

These words are unhelpful, anyway, in so far as colloquial use of them
can conflict with the boolean use:  English sometimes treats And as Set
Union, and treats Or as Intersect Not.  "Find documents containing
'cars' or 'buses'"....  [cf Alan Cooper's "About Face"]

I would "simplify" the original code just by leaving the word "then"
out.  The block structure simplifies re-structuring the code in the
future.  Also, error flags are probably best dealt with using raise
and begin...rescue...end blocks, IMHO.

>
> Guy Decoux
>

        Hugh