# Understanding object\_id in Ruby 2.7

**URL:** <https://www.ruby-forum.com/t/understanding-object-id-in-ruby-2-7/260268>\
**Category:** Ruby\
**Created:** [September 15, 2020, 9:56pm UTC](https://www.ruby-forum.com/t/understanding-object-id-in-ruby-2-7/260268 "2020-09-15T21:56:24Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![SouravGoswami](https://www.ruby-forum.com/user_avatar/www.ruby-forum.com/souravgoswami/32/2543_2.png) [@SouravGoswami](https://www.ruby-forum.com/u/SouravGoswami)\
**Post date:** [September 22, 2020, 1:30pm UTC](https://www.ruby-forum.com/t/understanding-object-id-in-ruby-2-7/260268/4 "2020-09-22T13:30:46Z")

</div>

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.

```auto
$ 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:

> **[Ruby 2.7 changes](https://rubyreferences.github.io/rubychanges/2.7.html#core-methods-returning-frozen-strings)**
>
> Ruby 2.7 full and annotated changelog

> **[Feature #16150: Add a way to request a frozen string from to\_s - Ruby master...](https://bugs.ruby-lang.org/issues/16150)**
>
> Redmine

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

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

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

```

---

_[View the full topic](https://www.ruby-forum.com/t/understanding-object-id-in-ruby-2-7/260268)._
