Ruby:我可以通过它的ID获取实例吗?

时间:2013-08-23 02:06:03

标签: ruby

在Ruby中,如果我将对象实例的ID作为字符串,例如 "#<Meeting:0x4531860>",我可以通过此ID获取实例吗?

# what I want
meeting = SOME_MAGIC_HERE "#<Meeting:0x4531860>"
# and then I can handle the meeting itself
meeting.name # => 'BLABLABLA'

1 个答案:

答案 0 :(得分:2)

meeting = ObjectSpace._id2ref(0x4531860 >> 1)