You can do
NOT_FOUND = 404
match value:
case v if v == NOT_FOUND:
pass
On its own this is a convoluted alternative to `if`, but it can be useful when we have lots of patterns.
Alternatively, we can avoid using a separate `v` variable and just use `value` directly:
NOT_FOUND = 404
match value:
case _ if value == NOT_FOUND:
pass
We can even match on a trivial value, and do all of the interesting checks using guards:
NOT_FOUND = 404
match None:
case _ if value == NOT_FOUND:
pass
This latter form acts like Lisp's `cond`, and I've used it a few times in Scala, e.g.
() match {
case _ if foo > bar => ...
case _ if foo < bar => ...
case _ if foo == bar => ...
}