forbes at lindesay.co.uk (2020-03-18T09:35:57.157Z)
Very interesting.
Once I wanted (and would have used a lot) something like a `switchMatch`.
It would work like this:
```js
switchMatch(value) {
case /\d+/: { ... }
case /\s+/: { ... }
case /.../: { ... }
default: {
console.log('Didn't match any of the options');
}
}
```
Of course you can have a regex like `(\d+)|(\s+)|...` but it would be more
readable and would allow situations like yours to be easily solved, read,
thought and taught.
Very interesting. Once I wanted (and would have used a lot) something like a `switchMatch`. It would work like this: switchMatch(value) { case /\d+/: { ... } case /\s+/: { ... } case /.../: { ... } default: { console.log('Didn't match any of the options'); } } Of course you can have a regex like `(\d+)|(\s+)|...` but it would be more readable and would allow situations like yours to be easily solved, read, thought and taught. [ ]s *--* *Felipe N. Moura* Web Developer, Google Developer Expert <https://developers.google.com/experts/people/felipe-moura>, Founder of BrazilJS <https://braziljs.org/>, Nasc <http://nasc.io/> and On2 <https://on2.dev/>. Website: http://felipenmoura.com / http://nasc.io/ Twitter: @felipenmoura <http://twitter.com/felipenmoura> Facebook: http://fb.com/felipenmoura LinkedIn: http://goo.gl/qGmq --------------------------------- * Changing the world* is the least I expect from myself! On Fri, Jan 31, 2020 at 6:57 AM Sultan <thysultan at gmail.com> wrote: > For example, the following: > > switch (value) { > case 0...9: break > case 'a'...'z': break > } > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20200131/5b57e7f1/attachment.html>