官术网_书友最值得收藏!

There's more...

Apart from extension functions, Kotlin also offers an extension properties feature. For example, we can declare a property for the List<T> class that will hold information about the last element index value:

val <T> List<T>.lastIndex: Int  get() = size - 1

Extensions are a widely used pattern across Kotlin standard library classes. They work seamlessly with Java, Kotlin, JavaScript, and native classes defined within the project and in external dependencies as well. 

主站蜘蛛池模板: 青浦区| 宝清县| 剑河县| 浏阳市| 泽库县| 化隆| 忻城县| 曲麻莱县| 方正县| 临江市| 大冶市| 璧山县| 习水县| 渭源县| 拜城县| 镇远县| 龙州县| 西乌珠穆沁旗| 香格里拉县| 四子王旗| 明星| 彝良县| 蒙阴县| 海兴县| 沙坪坝区| 万载县| 哈巴河县| 衡东县| 阳泉市| 广南县| 清远市| 德惠市| 桂平市| 介休市| 泰安市| 恩施市| 峨山| 东至县| 美姑县| 榆树市| 洪泽县|