Ruby - 如何重现指针/引用行为?
我目前正在尝试为新应用程序创建一个引擎。
设计非常复杂,我确实需要一种方法来创建引用或指针或任何远程修改和访问数据的方法。数据必须保存在一个地方,并且不得重复。
有没有办法通过引用获取对象? 例如,我可以获取带有 object_id 的类的实例吗?
感谢您的帮助 ;)
I am currently trying to create an engine for a new application.
Design is quite complex and i realy need a way to create a reference or a pointer or what ever way to remotely modify and access the datas. Datas must be kept in a single place and must not be duplicated.
Is there a way do get an object by reference ?
For example can I get the instance of a class with his object_id ?
Thanks for your help ;)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下内容应演示如何获取对对象的引用并取消引用它:
您可能希望查看 对象和ObjectSpace。
The following should demonstrate how to get a reference to an object and de-reference it:
You may wish to review the documentation for Object and ObjectSpace.
不确定您到底想要实现什么目标。 Ruby 已经使用所有自定义对象的引用。
您可能想查看
delegate
库。Not sure exactly what you want to achieve. Ruby uses references for all custom objects already.
You may want to look at the
delegate
library.