From: jayce@... (Jayce Piel) Date: 2002-04-04T22:11:46+09:00 Subject: Re: Test the result of an initialization ? Yohanes Santoso wrote: > jayce@mosx.net (Jayce Piel) writes: > > > What I want is if the path is not a path to a file, the object is not > > created. I try to do a "return nil" in initialize, but it has no effect. > > class ArchiveFile > def initialize(filename) > if not File.stat(filename).file? > raise "#{filename} is not a valid file" > end > end > end Hmmm... But the fact remains... Where must I put the catch ? > The return of #initialize is ignored. That's what I see... :-/ > #initialize is called by #new, > and #new returns only the created object, not the return from > #initialize. And then, I need to redefine #new to return nil when initialization fails ? Then, my catch must be in #new ? > BTW, there are already packages that handle tar and zip files. Ok, but it's an "exercice of style", just to learn the language... And I didn't find any package for tar... (And I need to deal with pax files too) -- Jayce Piel ( jayce@mosx.net ) Site Web sur MacOS X (Server) en fran�ais : Pourquoi il ne faut pas activer le compte root ? R�ponse :