Extractors are identified by the extractorExpression => match
expression. Extractors consist of two parts, which are separated by the =>
operator.
_
are replaced with the currently matched value.Since the right side is a pattern, it can contain another extractor. The following example "chains" two extractors:
static public function main() {
switch(3) {
case add(_, 1) => mul(_, 3) => a:
trace(a); // mul(add(3 + 1), 3)
}
}
static function add(i1:Int, i2:Int) {
return i1 + i2;
}
static function mul(i1:Int, i2:Int) {
return i1 * i2;
}
It is currently not possible to use extractors within or-patterns. However, it is possible to have or-patterns on the right side of an extractor.