title: Scala - how to build an immutable map from a collection of Tuple2s?
body: <p>In Python, a dictionary can be constructed from an iterable collection of tuples:</p>
  
  <pre><code>&gt;&gt;&gt; listOfTuples = zip(range(10), [-x for x in range(10)])
  &gt;&gt;&gt; listOfTuples
  [(0, 0), (1, -1), (2, -2), (3, -3), (4, -4), (5, -5), (6, -6), (7, -7), (8, -8), (9, -9)]
  &gt;&gt;&gt; theDict = dict(listOfTuples)
  &gt;&gt;&gt; theDict
  {0: 0, 1: -1, 2: -2, 3: -3, 4: -4, 5: -5, 6: -6, 7: -7, 8: -8, 9: -9}
  &gt;&gt;&gt; 
  </code></pre>
  
  <p>Is there an equivalent Scala syntax?  I see that you can use a varargs type amount of Tuple2s to construct a map, e.g.</p>
  
  <pre><code>scala&gt; val theMap = Map((0,0),(1,-1))
  theMap: scala.collection.immutable.Map[Int,Int] = Map((0,0), (1,-1))
  
  scala&gt; theMap(0)
  res4: Int = 0
  
  scala&gt; theMap(1)
  res5: Int = -1
  
  scala&gt; val tuplePairs = List((0,0),(1,-1))
  tuplePairs: List[(Int, Int)] = List((0,0), (1,-1))
  
  scala&gt; val mapFromIterable = Map(tuplePairs)
  &lt;console&gt;:6: error: type mismatch;
   found   : List[(Int, Int)]
   required: (?, ?)
         val mapFromIterable = Map(tuplePairs)
                                   ^
  </code></pre>
  
  <p>I could loop through and assign each value manually, but it seems like there must be a better way.</p>
  
  <pre><code>scala&gt; var theMap:scala.collection.mutable.Map[Int,Int] = scala.collection.mutable.Map()   
  theMap: scala.collection.mutable.Map[Int,Int] = Map()
  
  scala&gt; tuplePairs.foreach(x =&gt; theMap(x._1) = x._2)                                     
  
  scala&gt; theMap
  res13: scala.collection.mutable.Map[Int,Int] = Map((1,-1), (0,0))
  </code></pre>