title: How is smart cast different from explicit cast in KOTLIN
body: <p>Recently I read about the smart cast performed by the <code>is</code> operator and also about the <code>as</code> or the better <code>as?</code>operators in that is used for explicit casting.</p>
  <p>The kotlin docs species their difference of usage as follows:-</p>
  <p><strong>Note that smart casts do not work when the compiler cannot guarantee that the variable cannot change between the check and the usage.</strong> More specifically, smart casts are applicable according to the following rules:</p>
  <ul>
  <li><p>val local variables - always except for local delegated properties;</p>
  </li>
  <li><p>val properties - if the property is private or internal or the check
  is performed in the same module where the property is declared. Smart
  casts aren't applicable to open properties or properties that have
  custom getters;</p>
  </li>
  <li><p>var local variables - <strong>if the variable is not modified between the
  check and the usage</strong>, is not captured in a lambda that modifies it,
  and is not a local delegated property;</p>
  </li>
  <li><p>var properties - never (<strong>because the variable can be modified at any
  time by other code</strong>).</p>
  </li>
  </ul>
  <blockquote>
  <p>Note that smart casts do not work when the compiler cannot guarantee
  that the variable cannot change between the check and the usage.</p>
  </blockquote>
  <p><strong>The above written is bit confusing, since the <code>var</code> variables can be changed after initialization and I could not find a example that can make it clear the actual insight of the statement.</strong></p>
  <p><strong>Can anyone make it easier to understand this insight better, in anyway?</strong></p>
  <p><strong>And does <code>is</code> operator provide some optimization benefit over the <code>as</code> operator if, any?</strong></p>