Please do not monkey patch core libraries in gems, unless the *purpose* of your library is to add functionality to core, eg a library of extensions like activesupport. Yes, this goes for additions as well as overrides. I cannot tell you how many times I've seen a "harmless addition" mess things up in confusing and hard to debug ways.
What method do you want to add to strings? -- Avdi Grimm http://avdi.org On Jun 19, 2012 1:35 PM, "Iain Barnett" <[email protected]> wrote: > Hi all, > > I'd like to add a method to the String class for a gem I'm making. > Obviously, I could just open it up and pop the method in, but I'd like to > know what is the state-of-the-art for adding a method. Do I get anything > better from putting the method in a module and then opening up the class > and including it? I can't see why but I'd like to know. > > I don't wish to use a new class that inherits from String because I > understand that there's a gotcha with String due to something done for > performance reasons (though I can't remember the exact details I remember > the warning!), and there's obvious good sides to the method being directly > in String that far outweigh the inheritance angle. > > Any thoughts or suggestions would be appreciated. > > Regards, > Iain > -- You received this message because you are subscribed to the Google Groups ruby-talk-google group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at https://groups.google.com/d/forum/ruby-talk-google?hl=en
