If I have this code in Scala below:
val prices = Map("bread" -> 4.56, "eggs" -> 2.98, "butter" -> 4.35)
prices.map((k,v) => (k, v-1.1)).toMap
I get the error:
The expected type requires a one-argument function accepting a 2-Tuple.
Consider a pattern matching anonymous function, `{ case (k, v) => ... }`
But when I change the second line to:
prices.map{ case(k,v) => (k, v - 1.1) }.toMap
The above error goes away? Can someone please explain when would I need to use case in the map function?