ngs
ngs copied to clipboard
=~ for Int
There are situations where it is known that the value is integer and we would like to check it against a pattern, like in ok:HERE my_command
(checks exit code). This case is different from the general case of pattern matching because we for example can match 1
with [0,1,2]
(which would mean 1 in [0,1,2]
)
Think: generalize to other types?
Maybe something like v =~ TypeSpecific(Int, pattern)
(can also assert the correct type)
Maybe v =~ Mode(Int, pattern)
Thought: v.assert(Int) =~ pattern
Thought: v =~ IntMatcher(....)
, throws exception when v
is not Int