3 ms·
I think forcing me to use "+=" in Ruby reminds me that it's really a method call (which can be overridden), rather than an increment operation on primitive type
by isomorphic 11y ago
I think forcing me to use "+=" in Ruby reminds me that it's really a method call (which can be overridden), rather than an increment operation on primitive types.
- odonnellryan 11y agoYes, this exactly! While rarely a good idea, it does give you super powers when dealing with specialized libraries, or when writing your own :)
- paulddraper 11y agoHave you ever written a container (with an iterator)?
- akira2501 11y agoAnd yet, ruby still provides 4 unary operators that can be redefined.
- BingsF 11y ago++ and -- (both versions of each) would end up being method calls as well in Ruby or Python. They're even overridable in C++.