title: Why does ?.let returns nullable even if it evaluates to a non-null
body: <p>Kotlin's standard function <code>let</code> is defined like this:</p>
  
  <pre><code>public inline fun &lt;T, R&gt; T.let(block: (T) -&gt; R): R
  </code></pre>
  
  <p>Doesn't this mean the return type of let will be whatever the block returns?</p>
  
  <p>Why doesn't this work?</p>
  
  <pre><code>var a: String? = "maybe null" 
  val x: Boolean = a?.let { 
      a.contains("maybe") // note that contains returns Boolean, not Boolean?
  }
  </code></pre>
  
  <p>This complains: <em>Type missmatch: Required <code>Boolean</code>, Found <code>Boolean?</code></em> Shouldn't it return a <code>Boolean</code> since <code>contains</code> function returns a <code>Boolean</code> ?</p>
  
  <p>I'm sure I've misunderstood something. Maybe someone can help me and other newbies to understand better.</p>