ngs icon indicating copy to clipboard operation
ngs copied to clipboard

=~ for Int

Open ilyash opened this issue 3 years ago • 4 comments

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?

ilyash avatar Jul 20 '21 06:07 ilyash

Maybe something like v =~ TypeSpecific(Int, pattern) (can also assert the correct type)

ilyash avatar Jul 20 '21 06:07 ilyash

Maybe v =~ Mode(Int, pattern)

ilyash avatar Jul 20 '21 06:07 ilyash

Thought: v.assert(Int) =~ pattern

ilyash-b avatar Aug 23 '22 17:08 ilyash-b

Thought: v =~ IntMatcher(....), throws exception when v is not Int

ilyash-b avatar Oct 14 '23 09:10 ilyash-b