title: In Kotlin How Can I Convert an Int? to an Int
body: <p>I'm using a <code>HashMap&lt;Int, Int&gt;</code> in Kotlin and when I <code>get</code> out of it the return type is <code>Int?</code>.</p>
  
  <p>How can I convert the <code>Int?</code> to an <code>Int</code>?</p>
  
  <p>So far I've tried using <code>Int?.toInt()</code>, but that seems to be returning an <code>Int?</code>.</p>
  
  <p>I'm writing a Fibonacci function, and my code looks like:</p>
  
  <pre><code>val fibMemo : Map&lt;Int, Int&gt; = HashMap&lt;Int,Int&gt;()
  fun fibN(n:Int) : Int {
      if (n == 0 || n == 1) return 1
      if (fibMemo.containsKey(n))
          // Error here: Type mismatch: inferred type is Int? but Int was expected
          return fibMemo.get(n)?.toInt()
      else {
          val newNum : Int = fibN(n-1) + fibN(n-2)
          fibMemo.put(n, newNum)
          return newNum
      }
  }
  </code></pre>