[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

object_hexid incorrect

T. Onoma

12/1/2004 2:49:00 PM

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.


2 Answers

ts

12/1/2004 3:02:00 PM

0

>>>>> "t" == trans (T Onoma) <transami@runbox.com> writes:

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

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


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


Guy Decoux


Ruben Vandeginste

12/1/2004 3:14:00 PM

0

At Wed, 1 Dec 2004 23:48:48 +0900,
trans. (T. Onoma) wrote:
>
> 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