From: Rick DeNatale Date: 2007-11-11T23:59:06+09:00 Subject: Re: The Man or Boy Recursion Test On Nov 11, 2007 9:21 AM, Tim Hunter wrote: > > I realized last night that the ||= is superfluous. A simple assignment > is enough. > > b = Proc.new { k -= 1; a(k, b, x1, x2, x3, x4) } Right, because b will always be nil here, it's a local variable so there's a new b for each resursion. Otherwise it would kind of defeat what the Man Or Boy example is trying to illustrate. And it can be made a little shorter, and more computer sciency , by replacing all those "Proc.new"s with "lambda"s. # Man or boy test def a(k, x1, x2, x3, x4, x5) b = lambda { k -= 1; a(k, b, x1, x2, x3, x4) } return k <= 0 ? x4[] + x5[] : b[] end puts a(10, lambda {1}, lambda {-1}, lambda {-1}, lambda {1}, lambda {0}) -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/