How to clone a case class instance and change just one field in Scala?

后端 未结 5 1635
难免孤独
难免孤独 2020-11-30 17:58

Let\'s say I have a case class that represents personas, people on different social networks. Instances of that class are fully immutable, and are held in immutable collecti

5条回答
  •  孤街浪徒
    2020-11-30 18:17

    existingPersona.copy(sentMessages = existingPersona.sentMessages + newMessage)
    

提交回复
热议问题