scala基础篇 源码中 :_*的作用

在scala源码中有大量的:_*,其作用是把Array、list转换为参数列表,作为变长参数传入参数列表

例子:

    def sumx(a:Int*)={
      a.sum
    }

    val a=Range(1,9)
    println(a.toString)
    println(sumx(a:_*))

 

posted @ 2021-08-16 14:57  梦里繁花  阅读(998)  评论(0编辑  收藏  举报