title: Scala: Update class field value
body: <p>I have:</p>
  
  <pre><code>case class One(someParam: String) {
  private val _defaultTimeout = readFromConfig("defaultTimeout")
  val timeout: Timeout = akka.util.Timeout(_defaultTimeout seconds)
  val info: Option[Info] = Await.result(someSmartService.getInformationForSomething(someParam)), timeout.duration)
  }
  </code></pre>
  
  <p>I'm building a service, which will obscure (encrypt) some sensitive data. I'm doing it in a such way:</p>
  
  <pre><code>def encrypt(oldOne: One): One = {
    val encryptedSomeParam = EncryptService.getHash(oldOne.someParam)
    val encryptedInfo = encryptInfo(oldOne.info)
    // what to do with that? ^^
    one.copy(someParam = encryptedSomeParam)
  }
  </code></pre>
  
  <p>Also, I need to encrypt some data inside this "info" field of class One. The issue is that it is a val and I cannot reassign the value of a val. Is there an easy way how to do that? For now I'm thinking about changing it to a var, but I think it's not the best way to do that. Also, I cannot write encrypted data to this value from the beginning like this:</p>
  
  <pre><code>val info: Option[Info] = EncryptionService.encrypt(someSmartService.getInformationForSomething(someParam))
  </code></pre>
  
  <p>As this field is used in other places where I need the fields to be not encrypted. I want to encrypt sensitive data before the persistence of the object to a database.</p>
  
  <p>Any ideas?</p>
  
  <p>Thanks in advance!</p>
  
  <p>EDIT: I know, that this looks like a bad design, so if someone has a better idea how to deal with it I'm looking forward to hear from you :)</p>