title: Destructuring Declarations in Kotlin
body: <p>I want to return multiple values from a function. As suggested by another SO answer, I used Destructuring with public class, but the problem is I can't assign the returned destructured result to already existing variables.</p>
  <pre><code>data class Result(val res1 :Int, val res2: Int)
  class test{
          fun retresult():Result{
          return Result(2,2)
      }
  }
  
  fun main(args: Array&lt;String&gt;) {
      var var1:Int = 0
      var var2:Int = 0
      var des = test()
      //(var1, var2) = des.retresult() this doesn't work
  
      var1 = des.retresult().res1
      var2 = des.retresult().res2 // **works but calls function twice** 
  }
  </code></pre>
  <p>I don't want to initialize local vals at return point like</p>
  <pre><code> val (var1, var2) = des.retresult()
  </code></pre>