سؤال

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