-
Notifications
You must be signed in to change notification settings - Fork 363
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
Peek operation for sequences and iterables #47
Comments
Do we need
|
I like the name |
We plan to make some optimizations of To implement We could either inline the operation in that lambda or not. The performance consequences of that options should be studied for both cases: when the operation is specified as a lambda itself |
Peek for Iterables
Another con: It creates another nested layer of curly braces and thus more indentation in many cases.
I have to agree here - the behavior definitely differs from
while
That would be sorted out by renaming Performance
Unfortunately I don't have much experience with this, especially since there may be differences between various VM implementations like ART, Dalvik and the JVM due to the JITs. |
The difference in evaluation order is not an issue, the same difference is observed if you change |
I believe it's the time to implement a prototype. You can either craft it as a pull request to the kotlin standard library if you're familiar with stdlib code generator or write manually in any other repository. |
Some implementation notes:
|
If I understood the DSL correctly, something like this should work. Ant kept crashing for me and I'm getting |
|
@cbruegg not quite right, but ok for starting point. I've elaborated those templates a bit, it required to improve the DSL to support such non-trivial constraints on generic receiver. The result is available in rr/stdlib/oneach branch. Could you check it out and try it with some tests? |
@ilya-g Sorry for the late response and thanks for fixing the template. I've had a look at the generated code and tried it out with some tests and everything seems to work as expected. I really like how we were able to implement this using Personally, I think this looks pretty much complete. |
Since we'd like to avoid inflating method count in stdlib, we're going not to provide |
… alternatives. Finalize name by replacing 'peek' with 'onEach' and renaming the proposal file itself.
Great, thank you for having worked on this! It's always great to see that JetBrains is really listening to feedback. |
What about |
Wanted to reask, what is about onEachIndexed? |
I think that |
Discussions about the
onEach
operation for sequences and iterables will be held here.The text was updated successfully, but these errors were encountered: