title: Reinterpret List[Any] as a List[Int]
body: <p>I have a <code>List</code> that I am sure only contains <code>Int</code> members, but the list is of type <code>List[Any]</code>. I need to sum the numbers in this list, but I can't use the <code>+</code> operator because it is not defined on <code>Any</code>.</p>
  
  <pre><code>scala&gt; val l = List[Any](1, 2, 3)
  l: List[Any] = List(1, 2, 3)
  
  scala&gt; l.foldLeft(0)(_ + _)
  &lt;console&gt;:9: error: overloaded method value + with alternatives:
    (x: Int)Int &lt;and&gt;
    (x: Char)Int &lt;and&gt;
    (x: Short)Int &lt;and&gt;
    (x: Byte)Int
   cannot be applied to (Any)
                l.foldLeft(0)(_ + _)
                                ^
  </code></pre>
  
  <p>I tried converting it to a <code>List[Int]</code> via <code>l.map(_.toInt)</code> but that of course failed for the exact same reason.</p>
  
  <p>Given a <code>List[Any]</code> that is actually a list of ints, how can I convert it to a <code>List[Int]</code>?</p>
  
  <p>For the curious, this is how I got here:</p>
  
  <pre><code>scala&gt; val l = List(List("x", 1), List("y", 2))
  l: List[List[Any]] = List(List(x, 1), List(y, 2))
  
  scala&gt; l.transpose
  res0: List[List[Any]] = List(List(x, y), List(1, 2))
  </code></pre>