@@ -660,6 +660,23 @@ Takes the optional values `exactly`, `at_least`, and `at_most` which makes `Some
660
660
either ` exactly ` _ n_ items, ` at_least ` _ n_ , or ` at_most ` _ n_ items (` at_least ` and ` at_most ` can be given at the same
661
661
time, but not together with ` exactly ` ).
662
662
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
+
663
680
664
681
### ` Between(lower, upper) `
665
682
@@ -800,7 +817,7 @@ if result := match("2020-08-27", Transformed(date.fromisoformat, 'date' @ _):
800
817
801
818
# ## `At(path, pattern)`
802
819
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
804
821
can not be resolved.
805
822
806
823
```python
0 commit comments