title: Kotlin: Return can be lifted out of 'when'
body: <p>The alternative to <code>switch</code> in Kotlin is <code>when</code>.  So, inside a recycler view adapter, when I am returning view type, I use <code>when</code>:</p>
  
  <pre><code>override fun getItemViewType(position: Int): Int {
      when (position) {
          0 -&gt; return ItemViewType.TITLE.type
          1 -&gt; return ItemViewType.SUBTITLE.type
          2 -&gt; return ItemViewType.ITEM.type
          else -&gt; return -1
      }
  }
  </code></pre>
  
  <p>But, the above statement sends our warning message <code>Return can be lifted out of 'when'</code>.  </p>
  
  <p>Does anyone know what may be the correct way of using <code>when</code>? And what should be done to fix the above case?  </p>