title: Check Android SDK Version with Kotlin using when
body: <p>I want to check the <em>Android</em> SDK version at runtime. I tried it like so:</p>
  
  <pre><code>fun Context.getDrawableById(resId : Int) : Drawable {
  
      when (Build.VERSION.SDK_INT) {
  
          in Int.MIN_VALUE..20 -&gt; return resources.getDrawable(resId)
          else -&gt; return getDrawable(resId)
      }
  }
  </code></pre>
  
  <p>I got a compiler warning <em>"Call requires API Level 21 (current min is 19)"</em>. So I changed my code:</p>
  
  <pre><code>fun Context.getDrawableById(resId : Int) : Drawable {
  
      if (Build.VERSION.SDK_INT &lt; 21)
          return resources.getDrawable(resId)
      else
          return getDrawable(resId)
  }
  </code></pre>
  
  <p>No compiler warning.</p>
  
  <p>My question is: is it possible to use <code>when</code> in this case without compiler warning? How?</p>