title: Can I use for-comprehenion / yield to create a map in Scala?
body: <p>Can I "yield" into a Map?</p>
  
  <p>I've tried     </p>
  
  <pre><code>val rndTrans = for (s1 &lt;- 0 to nStates;
                      s2 &lt;- 0 to nStates
                          if rnd.nextDouble() &lt; trans_probability)
                              yield (s1 -&gt; s2);
  </code></pre>
  
  <p>(and with <code>,</code> instead of <code>-&gt;</code>) but I get the error</p>
  
  <pre><code>TestCaseGenerator.scala:42: error: type mismatch;
   found   : Seq.Projection[(Int, Int)]
   required: Map[State,State]
      new LTS(rndTrans, rndLabeling)
  </code></pre>
  
  <p>I can see why, but I can't see how to solve this :-/</p>