title: Initializing custom delegates in Kotlin
body: <p>This seems to me like a trivial problem, but I was unable to find an answer, so here it is !</p>
  <p>I'm writing a simple Delegated property which I want to use like this ( with an initial value ) :</p>
  <pre class="lang-kotlin prettyprint-override"><code>val name by MyDelegate (&quot;Initial Name&quot;)
  </code></pre>
  <p>Here is my class for the delegated Property :</p>
  <pre class="lang-kotlin prettyprint-override"><code>class MyDelegate (val init: String) {
      var initialized = false
      operator fun getValue(thisRef:Any, property: KProperty&lt;*&gt;): String 
     {
          if (!initialized) { 
              setValue(thisRef,property,init)
              initialized = true
          }
          // return the actual value
      }
      operator fun setValue(thisRef:Any, property: KProperty&lt;*&gt;, value: String) {
          // set value
      }
  }
  </code></pre>
  <p>Is there a less ugly way to create a delegated property with an initialization, saving the use of one Boolean and one test every time ?</p>
  <p>Thank very much you for your attention !</p>