object_hexid incorrect

  • Thread starter trans. (T. Onoma)
  • Start date
T

trans. (T. Onoma)

Can anyone help me understand why these are not the same, and how to fix?

class Object
def object_hexid
return "0x#{'%x'%(self.__id__)}"
end
end

o.inspect
=> "#<Object:0x40335764>"

o.object_hexid
=> "0x2019abb2"

Thanks,
T.
 
T

ts

t> => "#<Object:0x40335764>"

t> o.object_hexid
t> => "0x2019abb2"


uln% ruby -e 'p "%x" % (2*0x2019abb2)'
"40335764"
uln%


Guy Decoux
 
R

Ruben

At Wed, 1 Dec 2004 23:48:48 +0900,
trans. (T. Onoma) said:
Can anyone help me understand why these are not the same, and how to fix?

class Object
def object_hexid
return "0x#{'%x'%(self.__id__)}"
end
end

o.inspect
=> "#<Object:0x40335764>"

o.object_hexid
=> "0x2019abb2"

Thanks,
T.

Did you notice that (0x40335764 >> 1) == 0x2019abb2 ?

Ruben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top