kvothe
kvothe

Reputation: 9

Scala: Search element of string List inside map(List<String>, Int)

In MyMap = scala.collection.mutable.Map[List[String], Int]() I have to match string inside MyMap, and get the value of corresponding Int. List of string represent topic of interest of my device, int is ID of device.

Upvotes: 0

Views: 231

Answers (1)

SCouto
SCouto

Reputation: 7926

Why don't yo use a filter, it do the same as find, but returning all the elements which satisfies the predicate

myMap.filter(_._1.contains("target")).map(_._2)

or even

myMap.filter(_._1.contains("target")).values

Upvotes: 1

Related Questions