I'm trying to update the value in a map[String, WordCount] while iterating this
case class WordCount(name: String,
                 id: Int,
                 var count: Double,
                 var links: scala.collection.mutable.HashMap[String, Double],
                 var ent: Double) {
    def withEnt(v: Double): WordCount = {println(s"v: $v"); copy(ent = v)}
}
var targets = mutable.HashMap[String, WordCount]()
The function calEnt is:
def calEnt(total: Double, links: scala.collection.mutable.HashMap[String, Double]): Double = {
    var p: Double = 0.0
    var ent: Double = 0.0
    links.map(d => {
      p = d._2 / total
      ent -= p * Math.log(p)
    })
    return ent
  }
And I'm using:
targets.map(m => m._2.withEnt(calEnt(m._2.count, m._2.links)))
for iterating the map and calculate the new value for ent and update this with withEnt. I can imprime in console the new value but it is not setting inside the map. What is the way to do that? please.
 
     
    