>> (1..100).inject(&:+)
TypeError: wrong argument type Symbol (expected Proc)
from (irb):1
I also am not a fan of doing things a thousand different obscure ways. I like doing things one way, and having that way highly optimized. Typing 10 characters or 20 characters doesn't impact my programming speed, I spend far more time thinking about how to do things the right way.edit:
Ok, did his monkeypatch and it worked. You get 5050. So it is equiv to sum(range(101)) in python, and much less readable. I fail to see why this is a good thing.
Why what is a good thing? Why that line of code is a good thing? maybe it isn't, maybe arrays need a sum method, maybe you could just write:
(1..100).inject { |acc, n| acc + n }
...and get the same result. But the article has nothing to do with why that line of code is a good thing, it is about the fact that being able to modify the Symbol class in this manner is what makes a langauge like Ruby evolve from the bottom up.
So... do you think that is a good thing? Or a bad thing?
So I am wondering why the author thinks its so fantastic.
As for developing the language, I am usually for flexibility and allowing anything to be modified, however this type of change strikes me as not very useful.
That's entirely the point. If you are in favour of flexibility, you have to accept that people will use it for all sorts of things, not just ones you like.
Anyways, I don't really care, saying anything other than 'I love ruby' is shunned anyways.
Well... I welcome criticism of Ruby. Please say whatever you like in a comment right on the post.
I've never shied away from writing about the things in Ruby that irritate me. How else will we progress if we don't scratch when we have an itch?
Any idea who specifically wrote it initially?