title: How to rewrite this "check, assign and return" pattern?
body: <p>Is there any clearer, more idiomatic way to rewrite this "check, assign and return" function?</p>
  
  <pre><code>fun getX(): Y {
      if (X == null) {
          X = ...
      }
  
      return X!!
  }
  </code></pre>
  
  <p><strong>Edit</strong>: I know of Elvis operator but the problem is that although I can save on few lines with syntax sugar</p>
  
  <pre><code>fun getX(): Y {
      X = X ?: ...
      return X!!
  }
  </code></pre>
  
  <p>I'm not changing the semantics of the code. I need to force casting anyway (<code>!!</code>). So it's the same, just three lines shorter.</p>
  
  <p><strong>Edit</strong>: <code>X</code> is a property on some object, and I need to update it.</p>