Kotlin 扩展函数之扩展属性

Posted 安果移不动

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Kotlin 扩展函数之扩展属性相关的知识,希望对你有一定的参考价值。

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 扩展函数之扩展属性的主要内容,如果未能解决你的问题,请参考以下文章