Difference between Any and generic type
<p>I have seen this function. I created this function with generic types but I saw this solution. I don't know if type the args with Any is better or there's different.</p>

<pre><code>def flatten(ls: List[Any]): List[Any] = ls flatMap {
    case ms: List[_] =&gt; flatten(ms)
    case e =&gt; List(e)
  }
</code></pre>

<p>or</p>

<pre><code>def flatten(ls: List[A]): List[A]
</code></pre>