9 ms·
No, both of those are bad monkey-patching. There is no reason for that function to be defined as a method in Array.
by SamReidHughes_ 17y ago
No, both of those are bad monkey-patching.
There is no reason for that function to be defined as a method in Array.
- sho 17y agoWell, admittedly, that should probably be a mixin, I just grabbed the first thing I saw. I don't see why it's so bad though - it's not like it's overriding anything.
- Psyonic 17y agoThe problem is that you throw this in your module, and then someone else defines another Array#to_sentence (say in some Natural Language module you require) and all of a sudden you've got hell on earth. For more information, take a look at some of the discussion about Array#sum: http://github.com/raganwald/homoiconic/blob/master/2009-04-09/my_objection_to_sum.md#readme http://github.com/raganwald/homoiconic/blob/master/2009-04-0...