hi, i have a string with the enconding reference like "#<MyObject: 0x2b9027de>" there any way to get the object from the string ? Thanks -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
object_id = "0x2b9027de".to_i(16) / 2 object = ObjectSpace._id2ref(object_id) -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/Dik43bsSoiYJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Aug 25, 12:53 pm, Maese <klbs.ma...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> hi, i have a string with the enconding reference like "#<MyObject: > 0x2b9027de>" > there any way to get the object from the string ? > ThanksTim''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 -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.