From: Joel VanderWerf Date: 2006-05-02T04:22:48+09:00 Subject: Re: Shortcut for [string].pack("p*").unpack("l").first ? Berger, Daniel wrote: > Hi all, > > If I want to get the underlying pointer address of a > Ruby string, I can do this: > > string = "hello" > [string].pack("p*").unpack("l").first # 43329024 > > I thought there was a shortcut for this. Originally I thought > perhaps object_id was identical, but that doesn't seem to be > the case. Maybe that was immediate types only. Even if you can munge object_id and get a pointer to the object, still, in the case of strings, you have to dereference from a field in the object to get to the actual string storage: struct RString { struct RBasic basic; long len; char *ptr; union { long capa; VALUE shared; } aux; }; -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407