From: William Morgan Date: 2005-02-15T00:01:44+09:00 Subject: Re: can anyone verify this code as correct? Hi, > foo = choices(1..100) > bar = choices(1..100) > condition(lambda{foo == (bar * 3)}) > condition(lambda{bar > 10}) > condition(lambda{(bar % 2) == 0}) Cute! Some comments: > def condition(cond) > return if (self.class == NilClass?) > @@cont.pop.call if !cond.call > end More idiomatic usage would be to take a block here, rather than requiring an explicit lambda. Then calling it looks like: condition { foo == bar * 3 } Also, you can drop the "class Object" declaration if you like, as top-level methods are automatically defined in Object. Or, move everything to a new class (even better). The real problem, though, is here: > class NilClass? > def method_missing(methId, *args) > return false > end > end Which has high potential to break existing code, or at least make debugging very difficult. I haven't thought this through thoroughly, but rather than returning nil, maybe you can jump to another continuation? Interesting idea, at any rate. The code is correct, though you have to drop the ? in NilClass?. -- William