Why doesn't `Regex` override `equals` ?
# stdlib
m
Why doesn't
Regex
override
equals
?
I know I can like compare them by using the
pattern
property but would be more convenient to not do so.
image.png
e
that's not correct: it'll falsely
"a".toRegex() == "a".toRegex(RegexOption.IGNORE_CASE)
as well as falsely
"a".toRegex() != "(?:a)".toRegex()
. since there's no good way to determine structural equivalence, it isn't attempted
👍 1
also of note: on JVM and JS, Kotlin's Regex is just a wrapper around the native Pattern or RegExp, neither of which support structural equality
👍 1
m
Oh I got it now Thank you for a good explanation
i
t
I think this is the first time I’ve read a thread on here that ephemient has participated in where they aren’t the one to link to the most relevant YT issue. 🙂
😂 1
⬆️ 5