📜  kotlin 合并两个具有交替值的列表 - 无论代码示例

📅  最后修改于: 2022-03-11 14:56:05.333000             🧑  作者: Mango

代码示例1
fun  List.mix(other: List): List {
    val first = iterator()
    val second = other.iterator()
    val list = ArrayList(minOf(this.size, other.size))
    while (first.hasNext() && second.hasNext()) {
        list.add(first.next())
        list.add(second.next())
    }
    return list
}