title: Cast Any to Array in Kotlin
body: <p>I'm initializing a class by loading data from a <code>Map&lt;String, Any&gt;</code> in Kotlin.  As this Map is gleaned directly from JSON, I don't know for certain that any given key exists, or that its value is of the type I expect.  To unpack this Map safely I'm doing the following, which appears to work perfectly:</p>
  
  <pre><code>a = rawData["A"] as? String ?: ""
  </code></pre>
  
  <p>Some of this data is in further nested JSON, which I'm unpacking to Arrays; I've tried to do this in the same way:</p>
  
  <pre><code>b = rawData["B"] as? Array&lt;String&gt; ?: arrayOf&lt;String&gt;()
  </code></pre>
  
  <p>However, when I attempt this using an array (as above) IntelliJ kicks up a fuss, saying</p>
  
  <blockquote>
    <p>Warning:(111, 30) Kotlin: Unchecked cast: Any? to Array&lt;String&gt;</p>
  </blockquote>
  
  <p>Is this just the IDE getting itself in a twist or is this method genuinely unsafe for Arrays despite being seemingly perfectly safe for other types?</p>