# IRB hex values

**URL:** <https://www.ruby-forum.com/t/irb-hex-values/94544>\
**Category:** Rails\
**Created:** [January 6, 2006, 12:47pm UTC](https://www.ruby-forum.com/t/irb-hex-values/94544 "2006-01-06T12:47:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 6, 2006, 12:47pm UTC](https://www.ruby-forum.com/t/irb-hex-values/94544/1 "2006-01-06T12:47:20Z")

</div>

Hi all,

Im working on a copy contact info into project method. Nosing aroundwith  
IRB I  
see a hex value. Named Contact:0x40ca01cc

#\<Contact:0x40ca01cc @attributes={“name”=\>“GP-net”, “id”=\>“7”,  
“lastname”=\>“Petersen”, “firstname”=\>“Gerard”}\>

Why is it there like that and not in a human readable way?

– Method:

@project = Project.new  
@project\_contact = ProjectContact.new

@contacts\_list = Contact.find\_by\_sql(‘select t1.name, t2.firstname,  
t2.lastname, t2.id from companies AS t1, contacts AS t2 where t1.id =  
t2.company\_id order by t1.name’)

@project\_contacts = @contacts\_list.collect { |c| [ c.name + " - " +  
c.firstname + " " + c.lastname, c.id ] }

render\_action ‘edit\_project’

– Models:

## class Project \< ActiveRecord::Base has\_one :project\_contact has\_many :project\_products end class ProjectContact \< ActiveRecord::Base belongs\_to :project end class ProjectProduct \< ActiveRecord::Base belongs\_to :project end

“Who cares if it doesn’t do anything? It was made with our new  
Triple-Iso-Bifurcated-Krypton-Gate-MOS process …”

My $Grtz =~ Gerard;  
~  
:wq!

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 6, 2006, 1:20pm UTC](https://www.ruby-forum.com/t/irb-hex-values/94544/2 "2006-01-06T13:20:23Z")

</div>

Gerard wrote:

> Hi all,
> 
> Im working on a copy contact info into project method. Nosing aroundwith IRB I  
> see a hex value. Named Contact:0x40ca01cc
> 
> #\<Contact:0x40ca01cc @attributes={“name”=\>“GP-net”, “id”=\>“7”,  
> “lastname”=\>“Petersen”, “firstname”=\>“Gerard”}\>
> 
> Why is it there like that and not in a human readable way?

That _is_ the human readable way 🙂 It’s Ruby’s internal ID for that  
specific Contact instance, rather than anything related to the database.  
if you did another Contact.find(7), you’d get the same DB info, but  
that hex number would be different.

I don’t know how it’s implemented internally, but I wouldn’t be  
surprised if it was a hash key, or an address lookup of some form.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 6, 2006, 6:18pm UTC](https://www.ruby-forum.com/t/irb-hex-values/94544/3 "2006-01-06T18:18:30Z")

</div>

Alex,

Thanx. I just thought I was asking my app the wrong questions.

Regards,

Gerard.

On Friday 06 January 2006 13:20, Alex Y. tried to type something  
like:

> That _is_ the human readable way 🙂 It’s Ruby’s internal ID for that  
> specific Contact instance, rather than anything related to the database.  
> if you did another Contact.find(7), you’d get the same DB info, but  
> that hex number would be different.
> 
> I don’t know how it’s implemented internally, but I wouldn’t be  
> surprised if it was a hash key, or an address lookup of some form.

–  
“Who cares if it doesn’t do anything? It was made with our new  
Triple-Iso-Bifurcated-Krypton-Gate-MOS process …”

My $Grtz =~ Gerard;  
~  
:wq!
