You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
someCollection.iterator.zipWithIndex.map { case (a, idx) => f(a, idx) }.to(SomeCollectionType)
Which is a little bit verbose just to avoid allocating the intermediate collection.
Additionally to the semantic improvement, since map is just a simple loop it is very easy to keep track of the index without any kind of overhead.
The text was updated successfully, but these errors were encountered:
I found myself doing this a lot:
Which is a little bit verbose just to avoid allocating the intermediate collection.
Additionally to the semantic improvement, since
map
is just a simple loop it is very easy to keep track of the index without any kind of overhead.The text was updated successfully, but these errors were encountered: