fun MutableList<Int>.swap(index1: Int, index2: Int) {
val tmp = this[index1] // “this” 对应该列表
this[index1] = this[index2]
this[index2] = tmp
}
fun MutableList<Int>.swap(index1: Int, index2: Int) {
val tmp = this[index1] // “this” 对应该列表
this[index1] = this[index2]
this[index2] = tmp
}
本文标题:扩展函数Kotlin
本文链接:https://www.haomeiwen.com/subject/kuplcqtx.html
网友评论