title: Idiomatic Kotlin when checking null
body: <p>In Java, I would do something like this:</p>
  
  <pre><code>class Person {
  
      private Record record;
  
      public String name() {
        record().get("name");
      }
  
      private Record record() {
        if (record == null) {
          refetch();
        }
        return record;
      }
  
      private void refetch() {
        record = service.doSomething()
      }
  
  }
  </code></pre>
  
  <p>In Kotlin, I have this equivalent code:</p>
  
  <pre><code>class Person(private var record: Record?) {
  
      fun name() : String {
        record().get("name");
      }
  
      private fun record() : Record {
        record ?: refetch()
        return record!!;
      }
  
      private fun refetch() {
        record = service.doSomething()
      }
  
  }
  </code></pre>
  
  <p>As you see, I'm using <code>!!</code> operator, and I don't really like. Is there another more idiomatic way to do this? </p>
  
  <p>If I simply follow the Java way (<code>if (record == null)</code>), I get this error: </p>
  
  <blockquote>
    <p>Smart cast to "Record" is impossible, because "record" is a mutable
    property that could have been changed by this time</p>
  </blockquote>