Possible Duplicate:
Tuple Unpacking in Map Operations
Lets say that I have the following Map[Int,Double]:
scala> map
res19: scala.collection.immutable.Map[Int,Double] = Map(1 -> 1.1, 2 -> 2.2)
I can run the following foldLeft on it:
scala> map.foldLeft("A")((initVal,x:(Int,Double)) => initVal + x._1)
res20: java.lang.String = A12
But I can't find a way to assign the tuple's values to named variables:
scala> map.foldLeft("A")((init,x:(a:Int,b:Double)) => init + x.a)
<console>:1: error: ')' expected but ':' found.
map.foldLeft("A")((init,x:(a:Int,b:Double)) => init + x.a)
^
Can this even be done?