This blog is part of our Ruby 2.4 series.
for representing small numbers
for big numbers.
In general routine work
we don’t have to worry about
whether the number we are dealing with
It’s just an implementation detail.
Ruby also has
which is superclass
Starting with Ruby 2.4, Fixnum and Bignum are unified into Integer.
Starting with Ruby 2.4 usage of Fixnum and Bignum constants is deprecated.
How to know if a number is Fixnum, Bignum or Integer?
We don’t have to worry about this change most of the times in our application code. But libraries like Rails use the class of numbers for taking certain decisions. These libraries need to support both Ruby 2.4 and previous versions of Ruby.
Easiest way to know whether the Ruby version is using integer unification or not is to check class of 1.
Look at PR #25056 to see how Rails is handling this case.
Similarly Arel is also supporting both Ruby 2.4 and previous versions of Ruby.