From: "ara.t.howard" Date: 2008-07-01T01:18:52+09:00 Subject: Re: nested methods good or bad design On Jun 30, 2008, at 9:42 AM, John Maclean wrote: > def method_1? > # here I check for some criteria > if %x[some_command] == "some criteria" > @this = true > end > > # every other method from here on depends on @this == true. Would > be nice to be able to skip the remained of the code if @this != true > > def method_2 > # do all of this stuff if @this = true > end this is *exactly* what closures are for def method_1 method_2 = @this ? lambda{ p 'yup' } : lambda{ p 'nope' } method_3 = @this ? lambda{ p 'a' } : lambda{ p 'b' } method_2.call method_3.call regards. a @ http://codeforpeople.com/ -- we can deny everything, except that we have the possibility of being better. simply reflect on that. h.h. the 14th dalai lama