I, for one, have often wanted to include this hex id when I customize an #inspect method for a class. But despite my lengthy efforts I have never been able to ensure the hex id is correct. It seems to vary a great deal depending on platform and Ruby version.
My last ditch approach will be to bind Kernel#inspect InstanceMethod to the current object and extract the hex id from it's output. It should work, but it's definitely a hack. In the future I'd much rather just ask Ruby for it!
I, for one, have often wanted to include this hex id when I customize an #inspect method for a class. But despite my lengthy efforts I have never been able to ensure the hex id is correct. It seems to vary a great deal depending on platform and Ruby version.
Thank you for 1.9.3+ definition, I will add that. Do you happen to know definition for 1.8.7? I am not worried about anything older than that.
Even if the method were added, it would never affect 1.9 or earlier, so it changes nothing for 1.8.7. Is the target of your library only 2.0 or later?
That's true. But if the definition should ever change again, this issue will come up again. So I think still better that Ruby make it's definition accessible.
My last ditch approach will be to bind Kernel#inspect InstanceMethod to the current object and extract the hex id from it's output. It should work, but it's definitely a hack. In the future I'd much rather just ask Ruby for it!