title: Access to external value inside apply
body: <p><em>Short example:</em></p>
  
  <pre><code>class MyClass {
   val someName = "want this value"
   val someOther = SomeOther().apply{ someName = someName }
   // other stuff below
  }
  </code></pre>
  
  <p><code>SomeOther</code> will apply the value of its own <code>someName</code> to <code>someName</code>, so value application makes no difference (x=x).</p>
  
  <p><strong>Q:</strong> How can I access external <code>someName</code> (<em>"want this value"</em>) being inside <code>apply</code>?</p>
  
  <p><strong>UPDATE</strong>
  I have further doubts related to suggestion to use <code>this.someName=someName</code>, below 2 code snippets, the first one works as expected, surprisingly the second fails with similar behavior as described.</p>
  
  <p><em>First</em></p>
  
  <pre><code>fun main(args: Array&lt;String&gt;) {
      class SomeOther {
          var someName: String? = null
      }
      val someName = "want this value"
      print(SomeOther().apply { this.someName = someName }.someName) // works!
  
  }
  </code></pre>
  
  <p><em>Second</em></p>
  
  <pre><code>class SomeOther {
      var someName: String? = null
  }
  
  class MyClass {
      val someName = "want this value"
      val someOther = SomeOther().apply { this.someName = someName }
      fun go() = print(someOther.someName)
  }
  
  fun main(args: Array&lt;String&gt;) = MyClass().go() // prints null
  </code></pre>
  
  <p><strong>Q:</strong> Where's the difference?</p>