Kotlin Merge Two Lists With Alternating Values

[Solved] Kotlin Merge Two Lists With Alternating Values | Kotlin - Code Explorer | yomemimo.com
Question : kotlin merge two lists with alternating values

Answered by : defiant-deer-y03a5cia8a33

fun <T> List<T>.mix(other: List<T>): List<T> { val first = iterator() val second = other.iterator() val list = ArrayList<T>(minOf(this.size, other.size)) while (first.hasNext() && second.hasNext()) { list.add(first.next()) list.add(second.next()) } return list
}

Source : https://stackoverflow.com/questions/66738374/kotlin-merge-two-list-with-alternating-values | Last Update : Thu, 15 Jul 21

Answers related to kotlin merge two lists with alternating values

Code Explorer Popular Question For Kotlin