Scala Map conversion
Posted
by Benjamin Metz
on Stack Overflow
See other posts from Stack Overflow
or by Benjamin Metz
Published on 2010-05-24T05:15:17Z
Indexed on
2010/05/24
5:21 UTC
Read the original article
Hit count: 239
scala
I'm a Scala newbie I'm afraid: I'm trying to convert a Map to a new Map based on some simple logic:
val postVals = Map("test" -> "testing1", "test2" -> "testing2", "test3" -> "testing3")
I want to test for value "testing1" and change the value (while creating a new Map)
def modMap(postVals: Map[String, String]): Map[String, String] = {
postVals foreach {case(k, v) => if(v=="testing1") postVals.update(k, "new value")}
}
© Stack Overflow or respective owner