Why, in the below code example, does isAList
\'s for
comprehension yield a List, but the other two yield Maps? I can\'t think of any reason - the on
Recently discussed on the ML:
https://groups.google.com/forum/#!msg/scala-internals/Cmh0Co9xcMs/D-jr9ULOUIsJ
https://issues.scala-lang.org/browse/SI-7515
Suggested workaround is to use a tuple to propagate the variables.
scala> for ((k,v) <- theMap; (dk,dv) = (k*2,v*2)) yield (dk,dv)
res8: scala.collection.immutable.Map[Int,String] = Map(2 -> unouno, 4 -> dosdos, 6 -> trestres)
More on the tupling mechanism:
What are the scoping rules for vals in Scala for-comprehensions