From: Eric Hodel Date: 2007-01-25T04:07:08+09:00 Subject: Re: Can Ruby do the Objective-C/Cocoa style alloc/init pattern? On Jan 24, 2007, at 01:50, Greg Hurrell wrote: > In Objective-C/Cocoa objects normally come to life in the following > way: > > instance = [[Class alloc] init]; > > The "Class" is sent an "alloc" message (memory is allocated and a new > instance is actually created) and then the new instance is sent an > "init" message (allowing the object to prepare itself for use). new is written like: class Object def self.new(*args, &block) obj = allocate obj.send(:initialize, *args, &block) # initialize is private obj end end -- Eric Hodel - drbrain@segment7.net - http://blog.segment7.net I LIT YOUR GEM ON FIRE!