-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
change match
arg order to match contains
?
#25584
Comments
This seems to make sense to me. A string |
I know, it makes sense by the verb(subject, object) convention, but it's just really annoying switching back and forth between the two orders for example, in this code: Lines 471 to 489 in 1c499c7
You can also say that a string matches a regex rather than that a regex matches a string, so the other order is linguistically justifiable as well. |
I've been bugged by the inconsistent order too. |
It's inconsistent with all The problem is that we cannot switch arguments for |
I guess we need a "contained in" operator. |
cf #19250 |
Pick one? |
Just put back |
Or maybe we don't need this at all, and OTOH #24303 gives a possible reason why we would want to have a dedicated function/operator (tentatively called |
We need something that actually returns the |
I don't think anybody suggested getting rid of |
The argument order "x contains y" makes too much sense to me to change. It can be understood by anybody who knows english, while the other argument order requires you to know the convention used by |
But if we renamed it or added e.g. |
We do the opposite for collections, i.e. "x in y". |
|
Yes, my point was that the smaller element (x) comes first. So it would make sense that in matching, the pattern which your looking for should also come first. |
We can always add a function that's like |
This is closed in #26283 where contains is deprecated to occursin. |
Having used it for a bit, I don't mind
contains(string, regex)
but the fact thatcontains(string, regex)
gets used a lot together withmatch(regex, string)
and they have different argument order is really a bummer. Perhaps we should changematch
and similar functions to take arguments in the other order? Since one of the arguments is a regex object, we could really support either order.The text was updated successfully, but these errors were encountered: