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

This looks awesome. You should consider sticking it somewhere and giving it a name, so that I might find it 6 months from now when I'm motivated to fix my shitty Python script [1].

Also, a side question: is it normal/considered a best practice in ruby to monkey-patch built-in libraries like that? I know ruby has open classes, but I'm just curious how using them in this way is regarded.

[1]: http://news.ycombinator.com/item?id=4494437




I put the link to the gist with the code for now, when I get a couple hours free sometime (soon I promise) I will do just that and put it on my github, so feel free to watch my account there.

As for patching string.rb I don't know 100% but I believe thats the point of being full OO is that I can make a patch like that where it makes sense to do it. I was using those functions in multiple places, and given they are meant for strings it made sense. I can see the potential pitfalls when it comes to sharing things like this, but again, Ruby makes it easy for anyone to make the same patch for a reason.


> Also, a side question: is it normal/considered a best practice in ruby to monkey-patch built-in libraries like that?

No, it's not considered to be good practice. I think it's generally frowned on by more experienced folk.

However, ActiveSupport (which is part of Rails) does a lot of monkey-patching of the basic Ruby classes in this way, and that probably helps to perpetuate monkey-patching among newer developers.




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

Search: