Get an object from the encoding reference

hi, i have a string with the enconding reference like "#<MyObject: 0x2b9027de>" there any way to get the object from the string ? Thanks

object_id = “0x2b9027de”.to_i(16) / 2

object = ObjectSpace._id2ref(object_id)

Tim's method works - but you should REALLY REALLY think about what's causing you to want to do this. This sort of trick could be handy when debugging, but using it in code that's meant to run reliably can wind up giving you some serious headaches. For instance, the object referred to by the string could get garbage-collected before you can dereference it...

--Matt Jones