669 B
669 B
Capture Patterns
In AVAP, capture patterns are used to bind the subject's value to a name. The syntax for a capture pattern is:
capture_pattern ::= NAME
Capture patterns always succeed and bind the value of the subject to the specified name.
Here’s how you might use capture patterns in AVAP:
match value:
case x:
print(f"Captured value: x")
In this example:
case x:captures whatever value is invalueand binds it to the namex. The pattern always succeeds.
Capture patterns are useful when you want to extract and use the value of the subject within your code, regardless of what that value is.