title: How to put an element to a map and return the map
body: <p>Consider this function, where we try to add an element to result of <code>toMap(): MutableMap&lt;String, Any&gt;</code>:</p>
  
  <pre><code>fun add(key: String, value: Any): MutableMap&lt;String, Any&gt; {
      val map = asMap()
      map.put(key, value)
      return map
  }
  </code></pre>
  
  <p>This is fairly simple, but I wonder if it could be possible to be simplified to a "one-liner"? Something like:</p>
  
  <pre><code>fun add(key: String, value: Any): MutableMap&lt;String, Any&gt;
      = asMap().magicPut(key, value)
  </code></pre>
  
  <p>EDIT: Obviously I was not clear enough: <code>asMap()</code> is a user defined function that returns a MutableMap with some entries. The <code>add</code> method should add to this already existing map.</p>
  
  <p>EDIT2: Based on comments I renamed <code>toMap()</code> to <code>asMap()</code>.</p>