title: Idiomatic way to check if some (not all) properties of two objects equal in Kotlin
body: <p>Let's assume i have a class with two instances:</p>
  <pre><code>class Car(val id: Int, val color: Color, val pistons: Int, val spoiler: Boolean)
  
  val audi = Car(1234, Color.BLUE, 8, false)
  val bmw = Car(4321, Color.WHITE, 6, false)
  </code></pre>
  <p>Now i'd like to check equality for some properties (not all -&gt; i'd use a data class in that case)</p>
  <pre><code>fun looksSimilar(a: Car, b: Car) = a.color == b.color &amp;&amp; a.spoiler == b.spoiler
  </code></pre>
  <p>I'm now looking for a method which does comparison:</p>
  <ul>
  <li>for more generic objects <code>T</code> and their properties</li>
  <li>more idiomatic: no-one wants to read tons of equals-checks</li>
  <li>similarly fast</li>
  </ul>
  <hr />
  <p>I've come up with the following proposal:</p>
  <pre><code>fun &lt;T&gt; Pair&lt;T, T&gt;.equalIn(vararg arguments: (T) -&gt; Any?) =
      arguments.toList().all { it(first) == it(second) }
  </code></pre>
  <p>which allows me to write the above check as</p>
  <pre><code>val looksSimilar = (audi to bmw).equalIn({it.color}, {it.spoiler})
  </code></pre>
  <p>Does anyone know a better (e.g. cleaner/faster) solution?</p>
  <hr />
  <p>My usecase is the following:</p>
  <p>I'm writing an Android App with multiple <code>RecyclerView's</code> (= fancy view to display lists)</p>
  <p>Each <code>RecyclerView</code> has a <code>ListAdapter</code> (responsible for the underlying list)</p>
  <p>Each <code>ListAdapter</code> requires a <code>DiffUtil.ItemCallback</code> (for comparing old &amp; new Items &amp; initiating appropiate changes in the view)</p>
  <pre><code>val callback = object : DiffUtil.ItemCallback&lt;Car&gt;() {
  
      override fun areItemsTheSame(oldItem: Car, newItem: Car): Boolean
      // usually checks for id, e.g. oldItem.id == newItem.id
  
      override fun areContentsTheSame(oldItem: Car, newItem: Car): Boolean
      // checks if two items look the same.
      // Used for fancy enter/exit animations afaik.
      // e.g. (oldItem to newItem).equalIn({it.color}, {it.spoiler})
  }
  </code></pre>