varargs parameter as type parameter?
Is there any way to create something similar to this:
class F[A] {def apply(a: A) = println(a)}
So that I can:
(new F[Int*])(开发者_如何学C1,2,3)
UPDATE: but otherwise, I want F to accept normal parameters:
(new F[Int])(1)
scala> class F[A] { def apply(a: A*) = a.length }
defined class F
scala> val instance = new F[Int]
instance: F[Int] = F@11a6631
scala> instance(1,2,3,4,5)
res4: Int = 5
精彩评论