Skip to content

Commit

Permalink
docs: add note about ||/&&
Browse files Browse the repository at this point in the history
  • Loading branch information
zkat committed Mar 23, 2018
1 parent e40d17e commit 33c27c6
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,26 @@ match (x) {
I don't think this is worth bikeshedding over unless there's major concerns
about syntactic ambiguity I haven't thought of.

#### > Use `||` and `&&` for joining

There was [some
discussion](https://github.com/tc39/proposal-pattern-matching/issues/7) about
different ways to join together multiple match patterns. This proposal picked `||`
for one-of, and `&&` for all-of matches:

```js
match (x) {
1 || 2 || 3 || x if (x > 10) => '...'
Bar {} && Foo {} => 'instanceof both Bar and Foo classes'
}
```

I believe this is better than `:` because, again, it distances itself more from
the very very different `switch` semantics, and also has a very clear symmetry
that allows `&&` to work just fine. It also fits with other pattern matching
engines that allow alternatives like this actually do. I don't believe this is
worth further bikeshedding.

### Bikesheds

These are things that have different tradeoffs that are worth choosing between.
Expand Down

0 comments on commit 33c27c6

Please sign in to comment.