I am wondering what this scala symbol is: _@
.
(Search engines have trouble with weird characters so it's hard to find anything on google...)
Here is the context:
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!")
}
}
}
(The types of onTrue
, onFalse
, onMissing
are JsonAST.JValue
)
It's legal to omit the space between
_
and@
in a pattern match, so in this case it's the same asThe effect of the @ operator is to alias the value matched on the left to the name on the right for the match.