scala-创建泛型数组(T: Manifest)

时间:2023-12-05 10:58:44
def arrayT[T: Manifest](ary: T*): Array[T] = {//接受多个参数
val arys = new Array[T](ary.length) //初始化一个数组
for (item <- 0 until ary.length)
arys(item) = ary(item)
arys
} arrayT(1, 2, 3)