scala奇怪的符号“_@”意思

scala weird symbol "_@" meaning

我想知道这个 Scala 符号是什么:_@

(搜索引擎无法识别奇怪的字符,因此很难在 google 上找到任何内容...)

上下文如下:

def doNodeParse(json: JValue): TreeNode = {
    json match {
        case JObject(List(JField("Condition", JObject(List(JField("var", JString(variableName)), JField("Operation", JString("LT")), JField("Value", JDouble(threshold))))),
                JField("onTrue", _@ onTrue),
                JField("onFalse", _@ onFalse),
                JField("onMissing", _@ onMissing)
                )) =>
                LessThanNode(variableName, threshold, doNodeParse(onTrue), doNodeParse(onFalse), doNodeParse(onMissing))

        case _ => {
            throw new Error("failed parsing json!")
          }
    }
}

(onTrueonFalseonMissing的类型为JsonAST.JValue)

在模式匹配中省略 _@ 之间的 space 是合法的,所以在这种情况下它与

相同
    case JObject(List(JField("Condition", JObject(List(JField("var", JString(variableName)), JField("Operation", JString("LT")), JField("Value", JDouble(threshold))))),
            JField("onTrue", _ @ onTrue),
            JField("onFalse", _ @ onFalse),
            JField("onMissing", _ @ onMissing)
            )) =>
            LessThanNode(variableName, threshold, doNodeParse(onTrue), doNodeParse(onFalse), doNodeParse(onMissing))

@运算符的作用是将左侧匹配的值作为匹配项右侧名称的别名。