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

eachWhere for maps #52

Open
netvl opened this issue May 25, 2019 · 0 comments
Open

eachWhere for maps #52

netvl opened this issue May 25, 2019 · 0 comments

Comments

@netvl
Copy link

netvl commented May 25, 2019

Currently it appears impossible to use eachWhere with a map. It is formally possible to invoke eachWhere on a Map[A, B], but it would result in this method using Iterable[(A, B)] as the output for setting the value, which causes type mismatch errors.

My use case is as follows. I have a map like Map[String, SomeValue] and I need to modify only those entries whose key satisfies some predicate:

val predicate: ((String, SomeValue)) => Boolean = {
  case (k, _) => someConditionOnKey(k)
}
modify(_.sources.eachWhere(predicate).nested.value)

Apparently there is no simple way to do it now. Having an ability to use eachWhere on a map would solve the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant