by tyre · 10y ago · 0 comments
https://github.com/rails/rails/blob/d61baee52adcd1baebe15f10...
You're welcome to try and merge that into Ruby core itself. That said, "I like whitespace" isn't a good reason to add a new operator over a method. Ruby is object oriented, meaning you are calling methods on objects.
if x.in? my_set # very ugly
With that said, I personally don't agree with the post.I wouldn't call the method "in?" but maybe "element_of?" or "member_of?" but besides that, I don't see the need for an operator.
What I love about ruby is its focus on making programming delightful rather than adhering to weird ass rules like 'Ruby is object oriented, meaning you are calling methods on objects.' that people pretend are laws of physics when really you can break them anytime you want, unlike laws of physics.
Similar to the way you can write
def foo
"bar"
end
instead of class Kernel
def foo
"bar"
end
endGenerally speaking, Ruby eschews syntax that invokes a protocol behind the scenes for a consistent 1:1 mapping between method syntax and the methods they invoke.