On Jun 29, 3:35=A0pm, J=F6rg W Mittag <JoergWMittag+Use... / GoogleMail.Com>
wrote:
> Yossef Mendelssohn wrote:
> > Maybe I'm misunderstanding the point of the 'else' clause, but
> > wouldn't you put code that "only gets executed if none of the rescue
> > clauses are (i.e., there is no exception)" in the main body of what
> > you're adding rescues to? (viz. begin block, method definition)
>
> Counterexample:
>
> begin
> =A0 puts "According to your theory, this shouldn't be evaluated, "
> =A0 puts "but it will."
> =A0 raise RuntimeError
> rescue
> else
> =A0 puts "This, however, won't."
> end

I could have explained that better. I was thinking more along the
lines of

    begin
      puts "This will be executed, "
      puts "as will this."
      raise
      puts "This, however, won't."
    rescue
    else
      put "And neither will this."
    end

Rob's a-e example points out the benefit of using the else clause, but
it's still strange and slippery to me. I've never run into a practical
need for it, though I'm not inclined to disbelieve him when he says he
has. It would be great to see a concrete example.

--
-yossef