ngs-lang / ngs

Next Generation Shell (NGS)
https://ngs-lang.org/
GNU General Public License v3.0
1.41k stars 43 forks source link

=~ for Int #465

Open ilyash opened 3 years ago

ilyash commented 3 years ago

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 commented 3 years ago

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

ilyash commented 3 years ago

Maybe v =~ Mode(Int, pattern)

ilyash-b commented 1 year ago

Thought: v.assert(Int) =~ pattern

ilyash-b commented 9 months ago

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