title: Is there a built in Kotlin method to apply void function to value?
body: <p>I wrote this method to apply a void function to a value and return the value.</p>
  
  <pre><code>public inline fun &lt;T&gt; T.apply(f: (T) -&gt; Unit): T {
      f(this)
      return this
  }
  </code></pre>
  
  <p>This is useful in reducing something like this:</p>
  
  <pre><code>return values.map {
      var other = it.toOther()
      doStuff(other)
      return other
  }
  </code></pre>
  
  <p>To something like this:</p>
  
  <pre><code>return values.map { it.toOther().apply({ doStuff(it) }) }
  </code></pre>
  
  <p>Is there a language feature or method like this already build in to Kotlin?</p>