Re:Map.merge() – One method to rule them all
by virtualwhys on Sunday March 31, 2019 @12:41PM
(#19536517)
Not the same but immutable approach is more idiomatic Scala.
List("hi", "there", "hi")
.zipWithIndex
.map { case (x, i) =>
x -> i
}.toMap
import scala.collection.mutable.Map
> val map = Map.empty[String, Int]
> List("hi", "there", "hi").map { x =>
> map(x) = i
> }