문제
나는 대답이 매우 간단하다고 확신하지만, 나는 이것에 갇혀있다 :
Welcome to Scala version 2.7.1.final (Java HotSpot(TM) 64-Bit Server VM, Java 1.6.0_14).
Type in expressions to have them evaluated.
Type :help for more information.
scala> def f(x:Int*)=0
f: (Int*)Int
scala> val xs:Seq[Int]=1::2::3::4::Nil
xs: Seq[Int] = List(1, 2, 3, 4)
scala> f (xs)
<console>:7: error: type mismatch;
found : Seq[Int]
required: Int
f (xs)
^
'int*'를 어떻게 구축합니까?
해결책
인수 목록에 시퀀스를 풀려면 사용 _*
scala> f(xs: _*)
res1: Int = 0
제휴하지 않습니다 StackOverflow