title: Ruby object to_s what is the encoding of the object id?
body: <p>In Ruby, the <code>to_s</code> on an object includes an encoding of the object's id.</p>
  
  <pre><code>[2] pry(main)&gt; shape = Shape.new(4,4)
  =&gt; #&lt;Shape:0x00007fac5eb6afc8 @num_sides=4, @side_length=4&gt;
  </code></pre>
  
  <p>In the documentation it says</p>
  
  <blockquote>
    <p>Returns a string representing obj. The default to_s prints the object’s class and an encoding of the object <a href="https://apidock.com/ruby/Object/id" rel="noreferrer">id</a>. 
    <a href="https://apidock.com/ruby/Object/to_s" rel="noreferrer">https://apidock.com/ruby/Object/to_s</a></p>
  </blockquote>
  
  <p>In the example above, the encoding of the object id is <code>0x00007fac5eb6afc8</code>.</p>
  
  <p>In <a href="https://stackoverflow.com/questions/3430280/how-does-object-id-assignment-work">How does object_id assignment work?</a> they explain </p>
  
  <blockquote>
    <p>In MRI the object_id of an object is the same as the VALUE that represents the object on the C level.</p>
  </blockquote>
  
  <p>So I compared to the <code>object_id</code> and it is not the same as the encoding of the object id.</p>
  
  <pre><code>[2] pry(main)&gt; shape = Shape.new(4,4)
  =&gt; #&lt;Shape:0x00007fac5eb6afc8 @num_sides=4, @side_length=4&gt;
  [3] pry(main)&gt; shape.object_id
  =&gt; 70189150066660
  </code></pre>
  
  <p>What exactly is the encoding of the object id?  It does not appear to be the <code>object_id</code>.</p>