Hi. I'm not clear on why these two scenarios are different. Can someone explain why the foldLeft code works, but the map(i)=z operation fails?
scala> def z(s: String) = s
z: (String)String
scala> val seed = Map.empty[Int, (String)=>String]
seed: scala.collection.immutable.Map[Int,(String) => String] = Map()
scala> List(1,2,3).foldLeft(seed) {(acc, next) => acc(next) = z}
res23: scala.collection.immutable.Map[Int,(String) => String] = Map(1 -> <function>, 2 -> <function>, 3 -> <function>)
scala> seed(1) = z
<console>:7: error: missing arguments for method z in object $iw;
follow this method with `_' if you want to treat it as a partially applied function
seed(1) = z
^
I know z _ will work, as per the message, but I don't understand how the latter operation differs from the foldLeft scenario. In both cases I invoke map(int)=<function>. What is the difference?
Thanks
Jeremy