Skip to content

Commit 985bf9f

Browse files
committed
Fix #11
1 parent 0b5b260 commit 985bf9f

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,23 @@ Takes the optional values `exactly`, `at_least`, and `at_most` which makes `Some
660660
either `exactly` _n_ items, `at_least` _n_, or `at_most` _n_ items (`at_least` and `at_most` can be given at the same
661661
time, but not together with `exactly`).
662662

663+
Note the difference between `Some(1, 2)` and `Some([1, 2])`. The first version matches subsequences, the second
664+
version matches items which are themselves lists:
665+
666+
```python
667+
match([0, 1, 2 , 1, 2 , 3], [0, Some( 1, 2 ), 3]) # matches the subsequence 1, 2 twice
668+
match([0, [1, 2], [1, 2], 3], [0, Some([1, 2]), 3]) # matches the item [1, 2] twice, which happen to be lists
669+
```
670+
671+
`Some` also goes by the names of `Many` and `Remaining`, which is sometimes nice to convey meaning:
672+
673+
```python
674+
match(range(1, 10), [1, 2, 'remaining' @ Remaining()])
675+
match([0, 1, 1, 1, 2, 1], [0, Many(1), Remaining(InstanceOf(int))])
676+
```
677+
678+
When used with no arguments, `Some()` is the same as `Some(...)`.
679+
663680

664681
### `Between(lower, upper)`
665682

@@ -800,7 +817,7 @@ if result := match("2020-08-27", Transformed(date.fromisoformat, 'date' @ _):
800817

801818
### `At(path, pattern)`
802819

803-
Checks whether the nested object to be matched satisfied pattern at the given path. The match fails if the given path
820+
Checks whether the nested object to be matched satisfies pattern at the given path. The match fails if the given path
804821
can not be resolved.
805822

806823
```python

0 commit comments

Comments
 (0)