Ari Brown wrote:
> Hey all,
> 
> I'm writing a quick DSL, and in it, I end up having to use return false 
> unless {} quite a bunch.
> 
> Since I still need everything outside of the return false's, Stefan 
> <apeiros>'s Stepper code is of no use, although it is still quite awesome.
> 
> Is there a way to alias it from, say:
> 
> return false unless { klass.method? }
> 
> to:
> 
> rule { klass.method? }


class RuleException < Exception; end

def rules
   yield
rescue RuleException
end

def rule(&b)
   raise RuleException unless yield
end

rules do
   p 1
   rule {true}
   p 2
   rule {false}
   p 3
end

__END__

Output:

1
2

-- 
       vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407