``` fun <T> List<T>.batch(batchSize:In...
# announcements
g
Copy code
fun <T> List<T>.batch(batchSize:Int): List<List<T>> {
    var startIndex = 0
    val ret = mutableListOf<List<T>>()
    while (startIndex < this.size){
        ret.add(subList(startIndex, (startIndex + batchSize ).coerceAtMost(size)))
        startIndex += batchSize
    }
    return ret
}
👍 3