3 ms·
But your python code is still really ugly. In Scala: import scala.collection.mutable.Map > val map = Map.empty[String, Int] > List("hi", "there", "hi").map {
by mruts 8y ago
But your python code is still really ugly. In Scala:
import scala.collection.mutable.Map
> val map = Map.empty[String, Int]
> List("hi", "there", "hi").map { x =>
> map(x) = i
> }
- virtualwhys 8y agoNot the same but immutable approach is more idiomatic Scala. List("hi", "there", "hi") .zipWithIndex .map { case (x, i) => x -> i }.toMap
- mruts 8y agoThat example doesn’t really illustrate the point of updating maps with repeated values.