I have the following code in Scala which works:
var queryMap = Map("name" -> "tim")
age_list.foreach { age => queryMap += ("age" -> age.toString) }
If I include placeholders in the function, it breaks:
var queryMap = Map("name" -> "tim")
age_list.foreach { queryMap += ("age" -> _.toString) }
The following error is thrown:
value += is not a member of scala.collection.immutable.Map[String,String]
queryMap becomes an immutable Map instead of a mutable Map. Is there something wrong with my syntax structure?