title: Kotlin: How convert from Set to Map?
body: <p>I have <code>Set&lt;FlagFilter&gt;</code> and I need to convert it to <code>Map&lt;Class&lt;out FlagFilter&gt;, FlagFilter&gt;</code>.</p>
  <p>I tried doing it like this:</p>
  <pre class="lang-kotlin prettyprint-override"><code>val result: Map&lt;Class&lt;out FlagFilter&gt;, FlagFilter&gt; =
       target
          .takeIf { !it.isEmpty() }
           ?.map { mapOf(it.javaClass to it) }
           ?: emptyMap&lt;&gt;()
  </code></pre>
  <p>but instead of a <code>Map</code> it turns out to be a <code>List</code> and I get a compilation error:</p>
  <pre><code>Type mismatch.
  Required: Map&lt;Class&lt;out FlagFilter&gt;, FlagFilter&gt;
  Found: List&lt;Map&lt;Class&lt;FlagFilter&gt;, FlagFilter&gt;&gt;
  </code></pre>
  <p>What am I doing wrong? As if there is not enough operation, but I do not understand yet which one</p>