Вопрос

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