From: Piers Cawley Date: 2001-09-07T18:25:15+09:00 Subject: [ruby-talk:20975] Re: calling original method in overrided method? Henry House writes: > I don't like the default behavior of String#to_i and String#to_f to return > zero for any string that contains no recognizable numbers. I had thought to > write overriding methods like so: > > Class String > def to_i > fail "#{self} is not a valid integer" unless self =~ /^\d*$/ Note that this will only find you positive integers. Maybe you mean self =~ /^[-+]?\d*$/ > # call original to_i > end > end > > ...but I don't how (if it is possible?) to call the original to_i. Am I stuck > with using a new method name or a custom string class? Frankly I'd hope that 'super' would do the job, but it seems from the rest of the thread that it doesn't... -- Piers Cawley www.iterative-software.com