Joel VanderWerf wrote: > 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? } Ignore previous post, it didn't really explain how you would have to use this construct: class RuleException < Exception; end def rules yield rescue RuleException false # be explicit and return false instead of nil end def rule(&b) raise RuleException unless yield end def some_method(arg) rules do rule {/foo/ !~ arg} rule {/bar/ !~ arg} true # could move this line after the "yield" end end p some_method("aaaa") p some_method("bar") __END__ Output: true false -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407