“Destructuring” a Map.Entry in a Scala closure
-
30-10-2019 - |
Question
val m: java.util.Map[String, Int] = ...
m.foreach { entry =>
val (key, value) = entry
// do stuff with key and value
}
Is there a better way to destructure the Map.Entry? I tried the following, but it does not compile:
m.foreach { (key, value) =>
// do stuff with key and value
}
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow