我有这两个快速的课程:
class A {
static func list(completion: (_ result:[A]?) -> Void) {
completion (nil)
}
static func get(completion: (_ result:A?) -> Void) {
completion (nil)
}
}
class B: A {
static func list(completion: (_ result:[B]?) -> Void) {
completion (nil)
}
static func get(completion: (_ result:B?) -> Void) {
completion (nil)
}
}
Run Code Online (Sandbox Code Playgroud)
尝试编译这会引发错误"覆盖声明需要'覆盖'关键字",但仅适用于B类的'get'方法.'list'方法编译良好.[B]有什么区别?和B?对于这种情况下的编译器?
编辑:另请注意,无法添加"覆盖".我收到错误'无法覆盖静态方法'.