-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Add new ?~
(boolean =~
) operator.
#4430
Add new ?~
(boolean =~
) operator.
#4430
Conversation
ab83659
to
318cfd3
Compare
Ruby 2.4.0 introduced
|
There's no need to do |
@asterite unfortunately, there is a need for it, since at times you'd like to have a |
I'll stick to fixing bugs. Maybe someone else can decide this better :-) |
In any case, the introduction of new operators must be very strongly justified. So this pull request should be rejected. But You can add usual method. P.S.: I'm glad to see how simple it is to expand the language |
@asterite I think having a strong opinion guiding the project is better than design by committee. I argued against some of your decisions in the past but it turns out that you were almost always right in the long run! Having too many operators is a bad thing, I think we have enough already. Using |
@RX14 I agree. It's just that I don't want to take decisions alone anymore. All decisions should be discussed by the whole core team. Here I rushed to close this because I'm against it, but I didn't consult it with anyone else. |
@asterite I was referring to the need of having |
I agree with limiting the number of operators in premise, but in this instance I'd agree with @reitermarkus that it does seem rather counterintuitive to provide the negative |
Ruby didn't actually introduce it for this, the reason was to remove the unnessary assignment to
Why is it a bad thing? It's not so much about the operators themselves, it's more about their usage, which in this case, is very specific.
I think |
As outlined by @asterite, there is no need for such an operator. It already works: if "something" =~ /regexp/
# match
end Maybe a |
Closing since there is enough consensus that we prefer not to create new operators without compelling reasons. In this case the general opinion is we can live without this. |
I always wondered why there is a
!~
operator, but not a boolean=~
operator.Usually, you would have to either use
!!(var1 =~ var2)
or
!(var1 !~ var2)
With this new operator, you can simply do this:
Let me know what you think, thanks!