Genuinely wondering what language that would have been valid in.
Genuinely wondering what language that would have been valid in.
Obviously, this is runtime code, not a type declaration, but you can see how a new or tired/busy developer’s brain might spit this out in the wrong place.
Have a brain fart one day and you'll write something like this and be confused why it doesn't work
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. states.find(state => state === 'VALID' || state === 'IN_PROGRESS')
Or states.find(state => ['VALID', 'IN_PROGRESS'].includes(state))Raku, but using “junctive or” | (which creates an any junction of its arguments, which “autothreads” on method calls producing a Junction of the results) instead of “tight or” ||.
Where statestype function ‘includes’ takes a lambda that’s run in states context and overrides plus operator for string to evaluate to states.contains(that string). One could, but should they?
IF X = 0 OR = 1 OR = 2
states.includes('VALID' | 'IN_PROGRESS')
is effectively the same as: states.includes('VALID') || states.includes('IN_PROGRESS')
See https://docs.raku.org/type/JunctionDoes this Python code count? Haha.
‘VALID’ or ‘IN_PROGRESS’ in states
Does not work and I’ve seen it around or SO. Or more commonly it’s variation a == b or c attribute:(value OR another_value)