title: Type mismatch from partition in Scala (expected (Set[String]...), actual (Set[String]...) )
body: <p>I have a partition method that creates tuple of two sets of string. </p>
  
  <pre><code>  def partition(i:Int) = {
      dictionary.keySet.partition(dictionary(_)(i) == true)
    }
  </code></pre>
  
  <p>I also have a map that maps integer to the return value from the partition method.</p>
  
  <pre><code>val m = Map[Int, (Set[String], Set[String])]()
  for (i &lt;- Range(0, getMaxIndex())) {
    m(i) = partition(i)
  }
  </code></pre>
  
  <p>The issue is that I have type mismatch error, but the error message does not make sense to me. </p>
  
  <p><img src="https://i.stack.imgur.com/4YSBx.png" alt="enter image description here"></p>
  
  <p>What might be wrong?</p>
  
  <p>This is the code:</p>
  
  <pre><code>import scala.collection.mutable.Map
  import scala.collection.{BitSet}
  
  case class Partition(dictionary:Map[String, BitSet]) {
    def max(x:Int, y:Int) = if (x &gt; y) x else y
    def partition(i:Int) = {
      dictionary.keySet.partition(dictionary(_)(i) == true)
    }
    def getMaxIndex() = {
      val values = dictionary.values
      (0 /: values) ((m, bs) =&gt; max(m, bs.last))
    }
    def get() = {
      val m = Map[Int, (Set[String], Set[String])]()
      for (i &lt;- Range(0, getMaxIndex())) {
        m(i) = partition(i)
      }
      m
    }
  }
  </code></pre>