Skip to content

Commit

Permalink
readme fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nystrom committed Nov 14, 2024
1 parent e32db40 commit a49ed7a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ Otherwise `2` is the result.
## Extractors

Struct patterns of the form `T(x,y,z)` can be overridden by defining an _extractor_ function for `T`.
When a value `v` of is being matched against a pattern `T(x,y,z)`, `Match.extract(T, v)` is called and the result is then matched against the tuple pattern `(x,y,z)`.
When a value `v` is matched against a pattern `T(x,y,z)`, `Match.extract(T, v)` is called and the result is then matched against the tuple pattern `(x,y,z)`.
The value `v` need not be of type `T`.
If `extract` returns a non-tuple (usually `nothing`), the `v` is checked against struct type `T` with it fields checked against the patterns `x, y, z`.
If the result of the `extract` call does not match the `(x,y,z)` tuple pattern, the value `v` is checked against struct type `T`, as usual, with its fields checked against the patterns `x, y, z`.

For example, to match a pair of numbers using Polar coordinates, extracting the radius and angle, you could define:
```julia
Expand Down

0 comments on commit a49ed7a

Please sign in to comment.