James Gray
8/24/2006 9:19:00 PM
On Aug 24, 2006, at 4:10 PM, Jeremy Lizt wrote:
> Is there an alternative method to String#to_i that will return nil
> instead of zero for invalid numerical strings?
Try this:
>> Integer("junk")
ArgumentError: invalid value for Integer: "junk"
from (irb):2:in `Integer'
from (irb):2
from :0
>> Integer("junk") rescue nil
=> nil
Hope that helps.
James Edward Gray II