C
Charles Comstock
Is there a way to create recursive anonymous closures in ruby? For instance
if I write
even = proc {|x| x == 0 ? true : odd(x-1)}
odd = proc {|x| x == 1 ? true : even(x-1)}
In this case even definitely doesn't know about odd, and actually doesn't even
know about even. Odd is aware of even though. At least that's how I have
interpreted how ruby works. We get recursion with full methods, just not with
anonymous procs. Is there any intention for support for this with anonymous
procs? Perhaps though a different syntax? procrec or something?
Charlie
if I write
even = proc {|x| x == 0 ? true : odd(x-1)}
odd = proc {|x| x == 1 ? true : even(x-1)}
In this case even definitely doesn't know about odd, and actually doesn't even
know about even. Odd is aware of even though. At least that's how I have
interpreted how ruby works. We get recursion with full methods, just not with
anonymous procs. Is there any intention for support for this with anonymous
procs? Perhaps though a different syntax? procrec or something?
Charlie