2 ms·
Putting regexes in multi-choices like that is not a new idea - you can also do it in Ruby: case "foo" when /hello/ when /oo/ puts "hi" end I guess
by yxhuvud 10y ago
Putting regexes in multi-choices like that is not a new idea - you can also do it in Ruby:
case "foo"
when /hello/
when /oo/
puts "hi"
end
I guess the new thing is having to state that it is a regex, which I assume is needed as the langauge here don't seem to have regex literals but are reusing strings (seriously, why do languages keep doing that? Did they learn nothing at all from Perl?)