Warum ändert sich das, wenn ich auf das Ergebnis eines MapValues zugreife? Sollte es nicht unveränderlich sein.Warum ändert Map.mapValues die Antwort?
Betrachten Sie die folgende Ammonitesitzung.
[email protected] import scala.util.Random
import scala.util.Random
[email protected] Seq("a").map(_ => Random.nextInt)
res1: Seq[Int] = List(1035918980)
[email protected] res1
res2: Seq[Int] = List(1035918980)
// re accessing Seq.map doesnt change
[email protected] Map("a" -> "a").mapValues(_ => Random.nextInt())
res3: Map[String, Int] = Map("a" -> 653125272)
[email protected] res3
res4: Map[String, Int] = Map("a" -> -694232910)
// re accessing Map.mapValues changes