assistance-engine/docs/developer.avapframework.com/chapter9_45.md

669 B
Raw Blame History

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.

Heres 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 in value and binds it to the name x . 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.