From: Gregory Brown Date: 2007-08-03T12:21:23+09:00 Subject: Re: Dynamic method call On 8/2/07, Pe�a, Botp wrote: > From: Gregory Brown [mailto:gregory.t.brown@gmail.com] > # do_something(..) if condition > # > # doesn't require anything. I'm still missing what value this > # if_is_true stuff is adding. > > i think he's asking for boolean obj so he can chain conditions. soemthing like, > > cond.if_true(foo).bar.blah.if_true.baz.light > > which is > > if cond > if x = foo.bar.blah > x.baz.light > end > end Sure, that could be helpful, but I'm not sure how you came up with that based on what was asked. For what you've shown there, I've often longed for a Null object something like class Null < BasicObject def self.method_missing(id,*args,&block) self end end module Kernel def if_true(condition) condition ? self : Null end end Note that I didn't even remotely test the above (though I have implemented this before for fun), but that hopefully the idea is preserved.