From: Stephen Waits Date: 2006-05-02T02:56:07+09:00 Subject: Re: Shortcut for [string].pack("p*").unpack("l").first ? Berger, Daniel wrote: > > If I want to get the underlying pointer address of a Insert standard confusion about someone worried about pointers in Ruby. Assume you know what you want. > Ruby string, I can do this: > > string = "hello" > [string].pack("p*").unpack("l").first # 43329024 > > Anyway, is there a shorter way? Or am I remembering > incorrectly? Why don't you just add it to String? irb(main):001:0> class String; def blah; [self].pack("p*").unpack("l").first; end; end => nil irb(main):002:0> "hello".blah => 43862144 --Steve