Skip to content

eachWhere for maps #52

@netvl

Description

@netvl

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions