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

24 lines
887 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## 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:
```javascript
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:
```javascript
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.