instance
、class
和 self
)在静态上下文中的用法。 在静态上下文中使用动态类型可能会令人混淆,因为该类型永远不会改变。
可以通过快速修复将动态类型用法替换为其静态等效项。
示例:
class Example
# 在静态上下文中使用 'instance'
INSTANCE: instance
# 在静态上下文中使用 'class'
CLASS: class
end
在应用快速修复后:
class Example
INSTANCE: Example
CLASS: singleton(Example)
end