title: How do I compare a Short with an Int in Kotlin?
body: <p>I have a <code>Short</code> variable that I need to check the value of. But the compiler complains that <code>Operator '==' cannot be applied to 'Short' and 'Int'</code> when I do a simple equals check:</p>
  <pre><code>val myShort: Short = 4
  if (myShort == 4) // &lt;-- ERROR
      println(&quot;all is well&quot;)
  </code></pre>
  <p>So what's the simplest, &quot;cleanest&quot; way to do this equals check?</p>
  <p>Here are some things I tried.</p>
  <p>The first one casts the 4 integer to a short (looks weird, invoking a function on a primitive number)</p>
  <pre><code>val myShort: Short = 4
  if (myShort == 4.toShort())
      println(&quot;all is well&quot;)
  </code></pre>
  <p>The next one casts the short to an int (shouldn't be necessary, now I have two ints when I shouldn't really need any)</p>
  <pre><code>val myShort: Short = 4
  if (myShort.toInt() == 4)
      println(&quot;all is well&quot;)
  </code></pre>