Skip to content

Commit d141554

Browse files
author
aless.hosry
committed
Comment MatcherObject class
1 parent 37509d9 commit d141554

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

MoTion/MatcherObject.class.st

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
"
2+
To define an object pattern, one specifies its type using the Pharo class followed by the percentage or double percentage operator like in: `ClassA % {}``. ‘%’ matches direct instances of the class, whereas ‘%%’ matches instances of the class or any of its subclasses.
3+
4+
These two operators can express sub-patterns and the properties of the matched object inside the curly braces. Object properties are instance variable accessors. The curly braces act as a conjunction of sub-patterns specifying the values that properties should match. It can be seen as a Logical matcher.
5+
The following pattern matches an object of class `ClassA`, with a property `property1` having the value `aValue1`, and `property2` having `aValue2`:
6+
```
7+
ClassA % {
8+
#’property1’ <=> aValue1.
9+
#’property2’ <=> aValue2.
10+
}
11+
```
12+
The sub-patterns could also be more complex (Nested pattern). This mechanism contributes to the seamless addition of various properties, in a declarative way.
13+
14+
"
115
Class {
216
#name : 'MatcherObject',
317
#superclass : 'Matcher',

0 commit comments

Comments
 (0)