From: nobu.nokada@... Date: 2004-07-06T18:55:37+09:00 Subject: Re: Initialize returning nil if error condition - how Hi, At Tue, 6 Jul 2004 16:37:49 +0900, Graham Nicholls wrote in [ruby-talk:105342]: > I've got "The Ruby Way" & "Programming Ruby", but can't find out how to have > an initializer return nil if theres a problem - something like this: Default Class#new always returns created instance unless any exceptions occurred. What you want isn't impossible by your own "new" class method, but raising an exception in "initialize" is much better. class CoverFile def initialize(fname) end def self.new(*args, &block) if obj = allocate() obj.__send__(*args, &block) end obj end end -- Nobu Nakada