Understanding object_id in Ruby 2.7

Kind of weird:

RVM:
$ ~/.rvm/rubies/ruby-2.7.1/bin/ruby -e “puts Object.new.object_id.<<(1).to_s(16)”
78

$ ~/.rvm/rubies/ruby-2.6.3/bin/ruby -e “puts Object.new.object_id.<<(1).to_s(16)”
558cb78027f0

$ ~/.rvm/rubies/ruby-2.5.5/bin/ruby -e “puts Object.new.object_id.<<(1).to_s(16)”
55ca2d7b62c0

$ ~/.rvm/rubies/ruby-2.4.6/bin/ruby -e “puts Object.new.object_id.<<(1).to_s(16)”
56536c0e9190

$ ~/.rvm/rubies/ruby-2.3.8/bin/ruby -e “puts Object.new.object_id.<<(1).to_s(16)”
55d614d03a78

System ruby:
$ ruby -e “puts Object.new.object_id.<<(1).to_s(16)”
78

Yes 2.7 changes it significantly.

$ for i in ~/.rvm/rubies/ruby-2.* ; do $i/bin/ruby -e "puts %Q(#{RUBY_VERSION} => #{''.object_id})" ; done
2.3.8 => 47416980288660
2.4.6 => 46983299641380
2.5.5 => 47335830802320
2.6.3 => 47393093047280
2.7.1 => 60

$ for i in ~/.rvm/rubies/ruby-2.* ; do $i/bin/ruby -e "puts %Q(#{RUBY_VERSION} => #{['a', 'b', 'c'].object_id})" ; done
2.3.8 => 47026568616500
2.4.6 => 47226028894120
2.5.5 => 47070111444620
2.6.3 => 47317018807680
2.7.1 => 60

Here’s more info:

It’s a good step towards performance, but if you ever need to modify those values:

> a = +true.to_s
=> "true"

> a << ?!
=> "true!"