-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
KT-8673: forEach analog which takes function with receiver for Iterable #1857
base: master
Are you sure you want to change the base?
Conversation
Thank you for your pull request. We haven't yet decided on the naming of the proposed function, but should we settle on |
@@ -441,4 +441,17 @@ object Mapping : TemplateGroupBase() { | |||
} | |||
} | |||
|
|||
val f_withEach = fn("withEach(operation: T.() -> Unit)") { | |||
include(Iterables) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider providing it for the same receivers as forEach
.
Also it makes sense to make it inline same as forEach
(note that different overloads have different inline modifiers)
data.withEach { | ||
substringList.add(substring(0, 1)) | ||
} | ||
assertEquals(2, substringList.size) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be just assertEquals(listOf("f", "b"), substrinList)
@ilya-g Thank you about feed back, now I tried to implement like |
This is related with: https://youtrack.jetbrains.com/issue/KT-8673