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

887 B
Raw Permalink Blame History

Wildcard Patterns

In AVAP, wildcard patterns are used to match any value without binding it to a name. The syntax for a wildcard pattern is:

wildcard_pattern ::=  '_'

Wildcard patterns always succeed and do not create any bindings. They are useful when you want to ignore the value of the subject and only care about whether it matches a certain pattern.

Heres how you might use wildcard patterns in AVAP:

match value:
    case _:
        print("Matched any value")

In this example:

  • case _: matches any value and does not bind it to a name. The pattern always succeeds, and the code within this case will be executed regardless of the value.

Wildcard patterns are particularly useful when you need to handle a broad range of possibilities and are only interested in whether a value fits a general condition, not in the value itself.