I am trying to update case class from an array.
Trying to update case class data inside an array, but I have to remove older record as well
I have tried as below
case class Data(str1: String, str2:String) { def updateMsg(msg : String) = this.copy(str2 = msg)}
val list = Array(Data("1", "2"), Data("2", "b"), Data("3", "c"))
list :+ list.filter(_.str1.equalsIgnoreCase("1"))(0).updateMsg("a")
I got results from above list as below
Array[Data] = Array(Data(1,2), Data(2,b), Data(3,c), Data(1,a))
Is there any better way to update existing case class row ?
scala 2.11
version, could please suggest me insteadarray
what will I have to use.