Skip to content
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

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

KT-8673: forEach analog which takes function with receiver for Iterable #1857

wants to merge 14 commits into from

Conversation

bloderxd
Copy link
Contributor

@bloderxd bloderxd commented Sep 9, 2018

@ilya-g
Copy link
Member

ilya-g commented Sep 11, 2018

Thank you for your pull request. We haven't yet decided on the naming of the proposed function, but should we settle on withEach, we might use this pull request as a base.

@@ -441,4 441,17 @@ object Mapping : TemplateGroupBase() {
}
}

val f_withEach = fn("withEach(operation: T.() -> Unit)") {
include(Iterables)
Copy link
Member

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)
Copy link
Member

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)

@bloderxd
Copy link
Contributor Author

@ilya-g Thank you about feed back, now I tried to implement like forEach was implemented.

@ilya-g ilya-g self-assigned this Dec 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants