Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我遇到过这段代码:
ListBuffer(comp: _*)
comp 是类型List[String]
List[String]
什么是ListBuffer(comp: _*)实现?具体来说comp: _* ?
comp: _*
ListBufferapply 方法采用某种类型的可变参数A。为了向它传递一些值序列,例如 a List,您可以使用不显式提取值_*的方法:从该序列中获取所有值(comp在您的情况下)并将它们作为参数传递给该函数。
ListBuffer
A
List
_*
comp