- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
菜鸟问题。我对包含此类的文件运行了 RubyMine 的代码检查。
class Square
attr_accessor :width
def area
@width * @width
end
end
我很惊讶地在 @width * @width
行收到两个警告:
找不到字段“@width”的声明
attr section of the Style Guide对我没有帮助。为什么这是一个警告?
----编辑----
Ruby-Doc说到 attr-accessor
Defines a named attribute for this module, where the name is symbol.
id2name
, creating an instance variable (@name
) and a corresponding access method to read it. Also creates a method calledname=
to set the attribute. String arguments are converted to symbols.
对我来说,“定义”意味着它有一个“声明”。警告消息没有意义。 “警告:字段在使用前可能未初始化”更准确。
我认为这是一个 RubyMine 问题(如果它真的是一个问题的话)。 RubyMine apparently uses its own code inspection protocol并且不使用标准的 Linter。
最佳答案
RubyMine 在这种情况下显示的警告是 known issue .
关于ruby - 检查警告 : Cannot find declaration for field,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37738412/
我是一名优秀的程序员,十分优秀!