4 ms·
You can do this in C#, which is similar if you squint. states.Any(s => s is "VALID" or "IN_PROGRESS") I'm sure there are languages where a match-able patt
by recursive 3y ago
You can do this in C#, which is similar if you squint.
states.Any(s => s is "VALID" or "IN_PROGRESS")
I'm sure there are languages where a match-able pattern is an expression, allowing the original code basically unchanged.
- simlevesque 3y agoYou can do it in JS too: states.find(state => state === 'VALID' || state === 'IN_PROGRESS') Or states.find(state => ['VALID', 'IN_PROGRESS'].includes(state))
- recursive 3y agoThis is a little further away IMO, as it doesn't have the `v1 or v2` construction.