title: Serializable in Kotlin
body: <p>In my Android app, I had a <code>TreeMap</code> that I could happily put in a <code>Bundle</code> like</p>
  
  <pre><code>bundle.putSerializable("myHappyKey", myHappyTreeMap);
  </code></pre>
  
  <p>but now that I'm porting my app to Kotlin, Android Studio complains that <code>Serializable!</code> is required, but it's finding a <code>Map</code> instead.</p>
  
  <p>How do I deal with this?</p>
  
  <p><strong>EDIT</strong> The warning seems to vanish if I cast my map to a <code>Serializable</code>. Is this the way?</p>
  
  <p><strong>EDIT 2</strong> I am declaring and initialising <code>myHappyTreeMap</code> as</p>
  
  <pre><code>var myHappyTreeMap: Map&lt;Int, Double&gt; = mapOf()
  </code></pre>
  
  <p>The <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/map-of.html" rel="noreferrer">documentation</a> says that maps initialised using <code>mapOf()</code> are serializable. If the docs says so…</p>