evkaky
07/10/2017, 1:14 PMenumerate(arr, fromId)
built-in function for that purpose:
for elem in enumerate(arr, 2): // elem = arr[2], arr[3] ... arr[n-1]
Is there something like that in kotlin std lib?gjesse
07/10/2017, 1:54 PMkotlin
fun <T> Iterable<T>.enumerate(startIdx: Int): Iterable<T> {
return this.filterIndexed { index, t -> index >= startIdx }
}
listOf(0,1,2,3,4)
.enumerate(2)
.forEach {
println(it)
}
marstran
07/10/2017, 2:28 PMfor (n in arr.drop(2)) { .. ]