Add `Integer.try_convert`

Again
This commit is contained in:
Marc-André Lafortune 2021-12-28 10:18:59 -05:00
parent 11acbfc41c
commit d1239bd716
3 changed files with 14 additions and 0 deletions

View File

@ -129,6 +129,10 @@ itself, JRuby and Rubinius.
- `dirname` (with depth argument)
#### Integer
- `try_convert`
#### MatchData
- `match`

View File

@ -0,0 +1,3 @@
require 'backports/tools/require_relative_dir'
Backports.require_relative_dir

View File

@ -0,0 +1,7 @@
class Integer
require 'backports/tools/arguments'
def self.try_convert(obj)
::Backports.try_convert(obj, ::Integer, :to_int)
end
end unless Integer.respond_to? :try_convert