title: How to convert Any to Int in Kotlin
body: <p>I have an attribute in my model defined as above that in some cases contain an Int.</p>
  
  <pre><code>var value: Any?
  </code></pre>
  
  <p>I know that I can do it if I cast first to String and then to Int</p>
  
  <pre><code>value.toString().toInt() // works
  </code></pre>
  
  <p>Is there a way of doing it by skipping casting into a String before?
  When I try to cast directly to into an Int I get this error</p>
  
  <pre><code>FATAL EXCEPTION: main
  java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer
  </code></pre>