我从这个问题得到以下代码:
def addChild(n: Node, newChild: Node) = n match {
case Elem(prefix, label, attribs, scope, child @ _*) => Elem(prefix, label, attribs, scope, child ++ newChild : _*)
case _ => error("Can only add children to elements!")
}
Run Code Online (Sandbox Code Playgroud)
除此之外,其中的所有内容都非常清晰: child ++ newChild : _*
它有什么作用?
我明白有Seq[Node]
与另一个连接Node
,然后呢?怎么: _*
办?