title: Combining/merging data classes in Kotlin
body: <p>Is there a way to merge kotlin data classes without specifying all the properties?</p>
  
  <pre><code>data class MyDataClass(val prop1: String, val prop2: Int, ...//many props)
  </code></pre>
  
  <p>with a function with the following signature:</p>
  
  <pre><code>fun merge(left: MyDataClass, right: MyDataClass): MyDataClass
  </code></pre>
  
  <p>where this function checks each property on both classes and where they are different uses the left parameter to create a new MyDataClass.</p>
  
  <p>Is this possible possible using kotlin-reflect, or some other means?</p>
  
  <p>EDIT: more clarity</p>
  
  <p>Here is a better description of what i want to be able to do</p>
  
  <pre><code>  data class Bob(
          val name: String?,
          val age: Int?,
          val remoteId: String?,
          val id: String)
  
  @Test
  fun bob(){
  
      val original = Bob(id = "local_id", name = null, age = null, remoteId = null)
      val withName = original.copy(name = "Ben")
      val withAge = original.copy(age = 1)
      val withRemoteId = original.copy(remoteId = "remote_id")
  
      //TODO: merge without accessing all properties
      // val result = 
      assertThat(result).isEqualTo(Bob(id = "local_id", name = "Ben", age=1, remoteId = "remote_id"))
  }
  </code></pre>