-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Provide a collectIndexed
terminal operator
#1247
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @jcornaz |
Hi @fvasco
Why not. except I'd call it But I think I prefer |
I agree.
In escape analisys we hope |
@jcornaz When you say "we occasionally need" can you provide a slightly more concrete example where this might be needed when you work with flows, please. E.g. if you had recently run into this need in your project, you can explain what was the problem you were solving. |
Last time I felt the need for it, it was to monitor progress. Here is how it'd look like: lines.collectIndexed { index, line ->
processLine(line)
println("${index + 1} lines processed")
} |
Hi,
Like with collections and sequences we occasionally need to iterate and maintain an index like this:
Since
forEachIndexed
already exists forIterable
andSequence
andconsumeEachIndexed
exists forReceiveChannel
it would seem natural to me that flows provide acollectIndexed
terminal operator.The text was updated successfully, but these errors were encountered: