title: Function that takes any collection as argument Scala
body: <p>I've been trying to write a function, that takes any collection that inherits Seq trait and performs action on it. I've come up with this:</p>
  
  <pre><code>def printAll[A, B &lt;: Seq[A]] (xs: B) = {
    xs foreach println
  } 
  </code></pre>
  
  <p>But this function works only with such arguments: </p>
  
  <pre><code>printAll(Seq.empty)
  printAll(List())
  </code></pre>
  
  <p>etc. How can I improve it to work in this way for example:</p>
  
  <pre><code>printAll(List(1,2,3)) // scala&gt; 1 2 3
  </code></pre>