From: Hugh Sasse Staff Elec Eng Date: 2001-06-28T23:28:03+09:00 Subject: [ruby-talk:17010] Re: Method overloading (option) Was: Re: On Thu, 28 Jun 2001, David Alan Black wrote: > Maybe just handle the exception: > > def split(obj) > a = [] > begin > len = obj.size > for i in 0...len > a.push obj[i] > end > rescue NameError > end > a > end > > > I'm not sure whether that might be casting too wide a net, though -- This is probably better than trying to add what I suggested. The only thing I'd want that I don't see is how to get the identity of object that raised the error out of NameError. NameError.methods doesn't suggest anything to me. > i.e., whether there might be a case where a NameError might come > about for some unrelated reason and you'd want it handled elsewhere. > Still, I think that for this kind of many-to-one error-to-outcome > ratio, exceptions might be a good way to go. > > > David > > -- > David Alan Black > Hugh