From: FreeMan Date: 2002-04-05T01:52:07+09:00 Subject: Re: Test the result of an initialization ? Jayce Piel wrote: > Ok, so that is near to the same problem that testing argument before > the call to #new... :-/ > By putting begin/rescue code around all call to #new, the code begins > to be unreadable... my understanding is that you want something like that : -- $arch = ArchiveFile.new('filename') -- with $arch being nil if filename doesn't exist. if i'm right then you're going to have to test if it's nil before doing anything with it ... and that's not really more readable than the rescue code. --your(i think) idea-- if ($arch = AchiveFile.new('filename') ) then ...do sg... else ...error... end --with rescue-- $arch = ArchiveFile.new('filename') rescue ...error... ....do sg... my 0.02? PS: maybe i've done some big mistakes :) i'm quite new to ruby. -- FreeMan /-- | "The concept of progress acts as a protective mechanism | to shield us from the terrors of the future." |Frank Herbert. Dune \--