3 ms·
The Scala snippet works for all inputs, it's something you would see on a real codebase. It also scopes the regex captures within the match expression. The code
by vvillena 2y ago
The Scala snippet works for all inputs, it's something you would see on a real codebase. It also scopes the regex captures within the match expression. The code also scales better for more complex cases where a string is tested against multiple regexes, or against specific captured values.
I assume this Kotlin snippet would, at minimum, need to do null-checking on "matchEntire" before it finds its way to a production codebase.