Hacker News new | past | comments | ask | show | jobs | submit login

No, both of those are bad monkey-patching.

There is no reason for that function to be defined as a method in Array.




Well, 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.


The 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-0...




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: