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
}

没有正确的解决方案

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top