Im trying to understand the following code, how the value in the variables a of case class dummy is being updated in the following code.
In the value method, I'm assigning the value of a to b , and adding new Node to b, which inturn it is reflecting the changes in a also. I don't understand how the value is a is being changed without even re-assignement.
object test {
  def main(args: Array[String]) {
    case class abc(str: String, var ele: abc)
    case class dummy(a: abc) {
      def value() = {
        var b = a
        println(s"Value of B before changing : ${b.str}") // Value of B before changing : Good
        println(s"Value of A before changing : ${a.str}") // Value of A before changing : Good
        val newObj = abc(" Morning", null)
        b.ele = newObj
        println(s"Value of A After changing : ${a.str},${a.ele.str}") // Value of A After changing : Good, Morning
        println(s"Value of B after changing : ${b.str},${b.ele.str}") // Value of B after changing : Good, Morning
      }
    }
    val testObj = dummy(abc("Good", null))
    testObj.value()
  }
}
 
     
    