Skip to content

Commit f6e92e2

Browse files
committed
links and touch ups
1 parent 357e9c9 commit f6e92e2

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

pages/docs/manual/v12.0.0/pattern-matching-destructuring.mdx

+5-4
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ if (person1.TAG) {
479479
**Note:** Rescript versions < 9.0 had a `when` clause, not an `if` clause.  Rescript 9.0 changed `when` to `if`.  (`when` may still work, but is deprecated.)
480480

481481
### Match on subtype variants
482-
You can refine a variant A to variant B using the variant type spread syntax in pattern matching. This is possible if variant B is a subtype of variant A.
482+
You can refine a variant A to variant B using the [variant type spread syntax](variant.md#variant-type-spreads) in pattern matching. This is possible if variant B [is a subtype of](variant.md#coercion) variant A.
483483

484484
Let's look at an example:
485485

@@ -549,7 +549,7 @@ Let's break down what we did:
549549

550550
Notice how we're able to match on parts of the main variant, as long as the variants are compatible.
551551

552-
The example above aliases the variant type spread to a variable so we can use it in our branch. But, you can just as easily match without aliasing if you don't care about the actual value for your branch:
552+
The example above aliases the variant type spread to a variable so we can use it in our branch. But, you can just as easily match without aliasing if you don't care about the value:
553553
<CodeTab labels={["ReScript", "JS Output"]}>
554554

555555
```res
@@ -577,7 +577,7 @@ function isPet(animal) {
577577
```
578578
</CodeTab>
579579

580-
Similarily, if you want to get really advanced, you can even pull out a single variant constructor. This works with and without aliases. Example:
580+
Similarily, if you want to get advanced, you can even pull out a single variant constructor. This works with and without aliases. Example:
581581

582582
<CodeTab labels={["ReScript", "JS Output"]}>
583583

@@ -615,7 +615,8 @@ type pets = Cat | Dog
615615
type fish = Cod | Salmon
616616
type animals = | ...pets | ...fish
617617
618-
// Notice `dog` isn't spread into the `pets` variant, but this still work due to subtyping
618+
// Notice `dog` isn't spread into the `pets` variant,
619+
// but this still work due to subtyping.
619620
type dog = Dog
620621
621622
let isPet = (animal: animals) => {

0 commit comments

Comments
 (0)