Variablebinding In addition to the standalone variable patterns, you can also add a variable to any other pattern. You simply write the variable name, an at sign (@), and then the pattern. This gives you a variable-binding pattern.
expr match {
case UnOp(“abs”, e @ UnOp(“abs”, _)) => e
case _ =>
}
thereisavariable-bindingpatternwith e asthevariable and UnOp(“abs”, _) as the pattern. If the entire pattern match succeeds, then the portion that matched the UnOp(“abs”, _) part is made available as variable e. As the code is written, e then gets returned as is.