875 B
875 B
Class Patterns
In AVAP, class patterns are used to match instances of specific classes. Here is a detailed overview:
class_pattern ::= name "(" [pattern_arguments ","?] ")"
- Pattern Syntax: A class pattern specifies the class name followed by a parenthesized list of pattern_arguments . The pattern matches instances of the specified class.
- Matching Instances: The pattern will match if the subject is an instance of the specified class and the pattern_arguments (if any) match according to the rules defined for the pattern.
- Usage: Class patterns are useful for deconstructing objects based on their class and extracting values from them, enabling more precise pattern matching.
These patterns provide a way to work with objects based on their class type and structure, facilitating more sophisticated pattern matching and value extraction.