quicklens
quicklens copied to clipboard
eachWhere for maps
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.