Yes, because withIndex creates IndexedValue for each item
I always use
forEachIndexed
instead of for + withIndex
g
gabrielfv
11/30/2018, 3:31 PM
I was wondering that, because it could happen to generate lazily rather than eagerly, which could make the impact negligible depending on the application.
g
gildor
12/01/2018, 3:34 AM
IndexedValue generated lazily on each element, but if you traverse all elements will be generated + 1 object for each element