From: David Alan Black Date: 2001-09-08T23:59:34+09:00 Subject: [ruby-talk:21002] Re: destructor Hello -- On Sat, 8 Sep 2001, Ned Konz wrote: > I'm new to Ruby, so sorry if I'm asking a FAQ: > > On Friday 07 September 2001 02:38 pm, Dave Thomas wrote: > > "Nat Pryce" writes: > > > Ruby uses blocks to scope resource allocation and deallocation to scopes > > > , just like C++ does with constructors/destructors. Look at the > > > File::open method for an example. > > > > I liked Nat's idea a lot, so how about this: > > > > module Resource > > def Resource.append_features(to) > > def to.use(*params, &blk) > > obj = new(*params, &blk) > > Why are you passing the block to new() here? What if it doesn't take one? The &blk thing is provisional, like *params: candle:~$ ruby -w def thing(*args,&blk) puts "no block" unless blk end thing ^D no block David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav