我试着写了下面的方法进行串联3只列出了一起:Scala中使用“_”代替显式类型
def f[A]: List[A] => List[A] => List[A] => List[A] = _ ++ _ ++ _
但得到这个编译时错误消息:
<console>:7: error: missing parameter type for expanded function
((x$1, x$2, x$3) => x$1.$plus$plus(x$2).$plus$plus(x$3))
def f[A]: List[A] => List[A] => List[A] => List[A] = _ ++ _ ++ _
是否可以写得比下面更简洁:
scala> def f[A](xs: List[A], ys: List[A], zs: List[A]) = xs ++ ys ++ zs
f: [A](xs: List[A], ys: List[A], zs: List[A])List[A]