更新时间:2023-01-26 22:12:13
a: A
是类型归属;参见 Scala 中类型归属的目的是什么?
: _*
是类型归属的特殊实例,它告诉编译器将序列类型的单个参数视为可变参数序列,即 varargs.
: _*
is a special instance of type ascription which tells the compiler to treat a single argument of a sequence type as a variable argument sequence, i.e. varargs.
使用 Queue.apply
创建一个 Queue
是完全有效的,该Queue.apply
具有单个元素是序列或可迭代的,所以这正是当你给单个 Iterable[A]
.
It is completely valid to create a Queue
using Queue.apply
that has a single element which is a sequence or iterable, so this is exactly what happens when you give a single Iterable[A]
.