0
点赞
收藏
分享

微信扫一扫

Kotlin 扩展函数之扩展属性

Brose 2023-03-16 阅读 66


Kotlin统计元音字母出现的个数

val String.numVowels
get() = count { "aeiouy".contains(it) }


fun <T> T.easyPrint(): T {
println(this)
return this
}

fun main() {
"The people‘s Republic of China".numVowels.easyPrint()
}

Kotlin 扩展函数之扩展属性_kotlin

举报

相关推荐

0 条评论