阅读 Rails 指南时,我注意到实际的对象常量存储一个表。
First, when the module keyword is processed, the interpreter creates a new entry in the constant table of the class object stored in the Object constant. Said entry associates the name "Colors" to a newly created module object. Furthermore, the interpreter sets the name of the new module object to be the string "Colors"
但是,当我尝试访问对象时,它只是返回
=> Object
有没有办法访问 Ruby 中对象常量的内部结构?或许可以瞥见带有所述 Module-object-to-name
的表格
映射。
最佳答案
Module.constants # ==> All constants
可能对你有帮助。
关于ruby-on-rails - 对象常量的内部结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47043926/