title: How to delay to assign a value to a val in kotlin?
body: <p>I define mContext as val and I need to assign a value to it in the fun onCreate.</p>
  
  <p>The code <code>private lateinit val mContext: Context</code> isn't correct, how can I do?</p>
  
  <pre><code>class UIMain : AppCompatActivity() {
  
      private val mContext: Context
  
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.layout_main)
  
          mContext = this
      }
  }
  </code></pre>
  
  <p><strong>Answer Strelok</strong></p>
  
  <p>The keyword <code>this</code> isn't always fit, just like the following code, so I think it's more handier to assign <code>this</code> to mContext.</p>
  
  <pre><code> private Context mContext;
  
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.layout_main);
  
          mContext=this;
  
          findViewById(R.id.btnClose).setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Toast.makeText(getApplicationContext(), "Hello A", Toast.LENGTH_LONG).show();
                  Toast.makeText(mContext, "Hello B", Toast.LENGTH_LONG).show();
                  //Toast.makeText(this, "Hello C", Toast.LENGTH_LONG).show(); //Doesn't work
                  finish();
              }
          });
      }
  </code></pre>