From: Trans Date: 2007-11-27T23:02:28+09:00 Subject: Re: FEATURE SUGGESTION: Accept default value for to_f and to_i On Nov 26, 9:15 pm, Mr Magpie wrote: > I suggest that to_i() and to_f() have an optional parameter added with > the default value of 0 (for backwards compatibility). > > This would allow code like > > if astring.to_f(nil) > # valid, so use it > else > # not a valid float, nil was returned, so handle error > end if (num = astring.to_f) == 0 # may or may not be valid begin num = Float(astring) rescue # not a valid float, nil was returned, so handle error end end # valid num, so use it You can wrap it in a "monkey patch" if you like. T.