class Integer

Public Class Methods

try_convert(obj) click to toggle source

Try to convert obj into an Integer, using Kernel::Integer method. Returns converted integer or nil if obj cannot be converted for any reason.

# File lib/try_convert.rb, line 16
def Integer.try_convert obj
  Integer(obj) rescue nil
end