From: Chris Date: 2002-04-05T01:52:09+09:00 Subject: Re: Test the result of an initialization ? In article <1fa4ola.1k42a53qwppdN%jayce@mosx.net>, jayce@mosx.net (Jayce Piel) wrote: > Ok, that's what I mean for "catch"... I just want to say "a specific > treatment for when an exception occurs". Something like this? irb(main):001:0> class MyFile irb(main):001:0> attr :name irb(main):001:0> attr :file irb(main):002:1> def initialize(name) irb(main):003:2> @name = name irb(main):004:2> begin irb(main):005:3* @file = File.open(name) irb(main):006:3> rescue irb(main):007:3> puts "#{name} is not a valid file." irb(main):008:3> @file = nil irb(main):009:3> end irb(main):010:2> end irb(main):011:1> end nil irb(main):012:0> a = MyFile.new("hello") hello is not a valid file. #