From: Nikodemus Siivola Date: 2002-06-25T17:46:52+09:00 Subject: Re: No exceptions from String#to_i On Tue, 25 Jun 2002, Yukihiro Matsumoto wrote: > It seems a good idea. Let me think about it. > Will you submit RCR just for a record? Done. Since it seems that core Integer, Float, String and Array are sort of core classes in Ruby, it might also be nice to redefine Object's to_s, to_i, to_f and to_a to call the long form if it exists. This way the long form would give the short one for free. Something like: class Object def to_s if respond_to? :to_str to_str else inspect end end def to_a if respond_to? :to_ary to_ary else [self] end end def method_missing( message, *args ) case message when :to_i then to_int if respond_to? :to_int when :to_f then to_flt if respond_to? :to_flt end end -- Nikodemus