-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Integer class for checking integer instead of Fixnum #62
Conversation
Since Fixnum and Bignum are unfied into Integer in Ruby 2.4+, a warning occurs for using Fixnum (or Bignum).
json 1.8.3 cannot be build with Ruby 2.4
@@ -22,7 +22,7 @@ def from(item) | |||
|
|||
def deparse_item(item, context = nil) # rubocop:disable Metrics/CyclomaticComplexity | |||
return if item.nil? | |||
return item if item.is_a?(Fixnum) | |||
return item if item.is_a?(Integer) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need a version-check for the Ruby version here?
(this might not be tested by the test suite right now)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this works with any version rubies.
- In ruby 2.3.x or older,
Integer
class is an ancestor ofFixnum
andBignum
. - In ruby 2.4+, all integers are
Integer
class.
So item.is_a?(Integer)
works in both cases.
Supporting Bignum
in older rubies is a difference, but it may work as intended.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yes, you are indeed correct!
@makimoto I think updating it in the Gemfile.lock is fine. You are correct that we don't necessarily need that in a library, but its useful to have the tests run with predictable versions. |
OK. I got it. |
@makimoto Merged - thanks for your contribution! |
Since Fixnum and Bignum are unfied into Integer in Ruby 2.4+, a warning
occurs for using Fixnum (or Bignum).