From: Lloyd Zusman Date: 2004-08-02T08:26:47+09:00 Subject: Re: Forward references? Mark Hubbart writes: > [ ... ] > > One other way is to use blocks: > > # code that does this: > def chunk(&block) ($CHUNKS||=[]) << block end > END{ $CHUNKS.reverse_each{|ch| ch[] } } > # end special code :) > > chunk do > > x = foo() > y = bar() > puts x > puts y > exit(0) > > end > > chunk do > > def foo > return "foo" > end > > def bar > return "bar" > end > > end > > Of course, you'd name it something other than chunk. And there's probly > a one liner for it, too, but I didn't have enough time to clean it up > much. This is probably a bit hard to maintain due to its not-so-obvious algorithm. But it's clever! Thank you very much. -- Lloyd Zusman ljz@asfast.com God bless you.