title: Iteration over Scala tuples
body: <p>In scala, we can get an iterator over a tuple as follows</p>
  
  <pre><code>val t = (1, 2)
  val it = t.productIterator
  </code></pre>
  
  <p>and even</p>
  
  <pre><code>it.foreach( x =&gt; println(x.isInstanceOf[Int]) )
  </code></pre>
  
  <p>returns true, we cannot do simple operations on the iterator values without using asInstanceOf[Int], since</p>
  
  <pre><code>it.foreach( x =&gt; println(x+1) )
  </code></pre>
  
  <p>returns an error: type mismatch;  found   : Int(1)  required: String</p>
  
  <p>I understand the issue with Integer vs. Int, but still the validity of isInstanceOf[Int] is somewhat confusing. </p>
  
  <p>What is the best way to do these operations over tuples? Notice that the tuple can have a mix of types like integers with doubles, so converting to a list might not always work. </p>