При работе с коллекциями в Kotlin не забывайте, что есть операторы с поддержкой индексов:
- withIndex
- filterIndexed
- mapIndexed
- flatMapIndexed
- foldIndexed
#kotlin #collections
https://kt.academy/article/fk-cp-indexed
Just because we use use functional processing function, does not stop us from using indices. Let's learn about withIndex and indexed variants of important functions.