Skip to content

Commit

Permalink
Add a note about pattern matching iterables. Closes tc39#4.
Browse files Browse the repository at this point in the history
  • Loading branch information
bterlson committed Jul 5, 2017
1 parent 2c696de commit 4d097c3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ match (arr) {
}
```

It is possible that array patterns could also match iterables, however it's not clear this design is desirable. First, it's not clear that users of pattern matching would expect array patterns to match any object with Symbol.iterable. Second, since pulling values out of an iterable is side-effecty, it introduces a lot of confusion around what the state of the iterable is in each match leg and it's not clear that side-effecty-by-default pattern matching is a good idea.

That said, destructuring does work on iterables so there is a strong alignment argument here.

## Literal Patterns
Literal patterns are string, number, boolean, null, and undefined literals and matches exactly that value. Examples:

Expand Down

0 comments on commit 4d097c3

Please sign in to comment.