Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我不断收到此错误:未初始化的常量 A::MYCONST 我的代码看起来像
class A MYCONST = "myconst" end class B < A TEST = A::MYCONST end
p RUBY_VERSION class A MYCONST = "myconst" end class B < A p TEST = A::MYCONST p defined? TEST end
输出:
"2.0.0" "myconst" "constant"
解释器抱怨是因为它期望B::A::MYCONST.
B::A::MYCONST
在类 B 中,在 line2 中定义的 const 可以由 any::A::MYCONST或 just引用MYCONST。
::A::MYCONST
MYCONST
如果我把解决这个问题所需的人力资源加起来,我们需要两天时间。由于某种原因,在我的 Mac 机器上代码停止工作,而在 Windows 机器上一切运行完美。
很难确定是出了什么问题,因为错误消息没有给我们任何线索,而是将我们指向了几个错误的方向,比如发送错误的 http 标头之类的。