如何调用超级扩展功能?
例如:
{
"Destination": {
"BccAddresses": [],
"CcAddresses": [],
"ToAddresses": [
"success@simulator.amazonses.com"
]
},
"Message": {
"Body": {
"Html": {
"Charset": "UTF-8",
"Data": "You have been removed from Kudo mailing list for account: bob@gmail.com"
},
"Text": {
"Charset": "UTF-8",
"Data": "You have been removed from Kudo mailing list for account: bob@gmail.com"
}
},
"Subject": {
"Charset": "UTF-8",
"Data": "Kudo email removal"
}
},
"ReplyToAddresses": [],
"ReturnPath": "",
"ReturnPathArn": "",
"Source": "donotreply@kudo.io",
"SourceArn": "arn:aws:ses:us-west-2:1xxxxxxxxxx2:identity/donotreply@kudo.io"
}
答案 0 :(得分:2)
即使在print()
内定义Parent
函数,它也属于String
,而不属于Parent
。因此,您可以在print
上调用Parent
功能,这是您尝试对super
进行的操作。
我不认为您在Kotlin尝试做的电话类型有语法支持。
答案 1 :(得分:0)
目前不可能,而且 kotlin 问题跟踪器中存在问题 - KT-11488
但您可以使用以下解决方法:
open class Parent {
open fun String.print() = parentPrint()
// Declare separated parent print method
protected fun String.parentPrint() = println(this)
}
class Child : Parent() {
override fun String.print() {
print("child says ")
parentPrint() // <-- Call parent print here
}
}