如果这是一个愚蠢的问题,道歉,Kotlin对我来说仍然是新的,我不熟悉语法“类型”,所以发现它很难找到解决方案。 fun Any?.test(): Any?
{
return this
}
"test string".test() // implicit string is now type of "Any"
"test string".test().substring() /
是否可以像这样在注释类型上定义Kotlin扩展函数? @ColorInt
fun @ColorInt Int.darken(): Int {
return ColorUtils.blendARGB(this, Color.BLACK, 0.2f)
}
另一种形式: @ColorInt
fun (@ColorInt Int).darken(): Int {
return