Sorry, to be a little more clear, the following 3 lines are all
equivalent (notice the parens in line 2):

if not thr or not thr.alive?
unless (thr or thr.alive?)
unless thr and thr.alive?

It's easiest for me to think of "unless" == "if not".  What's funny is
that "if not" is no longer than "unless", so the "unless" keyword
doesn't buy us much.

On 8/18/05, Patrick Fernie <patrick.fernie / gmail.com> wrote:
> When you check thr directly, since thr is not nil (it is still a
> Thread object, just dead), those parts of the test evaluate "true".
> So, in:
> "HERE" if not thr or not thr.alive?
> the "not thr" evaluate false (since thr is an object, and therefore
> not nil), but the "not thr.alive?" evaluates true (not false), so
> "HERE" is printed since one of the tests is true
> 
> in:
> "HERE" unless thr or the.alive?
> "thr" is not nil, so it's true, so we short circuit and don't print,
> since it's an unless.
> 
> in:
> "HERE" unless the and the.alive?
> "thr" is not nil, so it's true, but thr.alive? is false, so the "and"
> overall evaluates to false, so "HERE" is printed since it's an unless.
> 
> Hope that makes sense.
> -Patrick
> 
> On 8/18/05, Zach Dennis <zdennis / mktec.com> wrote:
> > thr = Thread.new{}
> > # thread dies
> >
> > "HERE" if not thr or not thr.alive? # this works!!
> > "HERE" unless thr or thr.alive? # doesn't work!! WHY?
> > "HERE" unless thr and thr.alive? # works, but why?
> >
> > I dont see why the unless/and works when the unless/or should be the one
> > short-circuting no?
> >
> > Thanks,
> >
> > Zach
> >
> 
> 


-- 
Brock Weaver
[OBC]Technique