正如标题中所述:为什么可以忽略子类型的重写成员函数中的默认值?
Is this normal or to be expected?
interface Foo {
fun bar(parameter: Int = 1)
}
class Baz : Foo {
override fun bar(parameter: Int) { // OK
println(parameter)
}
}
val baz = Baz()
baz.bar() // OK
baz.bar(2) // OK
Same behavior in the case where Foo
is a class.