On 23.04.2009 23:30, Marc Heiler wrote:
> Recently I added
> def strip!
> to class Array. I found that I needed it, and some of my arrays were
> collection of strings having whitespace.

Why didn't you choose to add this to module Enumerable?  Restricting 
this to Arrays does not seem to make much sense.

> It was trivial, and I thought
> this could be part of standard ruby.

The reason to include something in standard Ruby is not the ease of 
implementation but rather the usefulness for a wide audience and many 
uses of the class.  Since your case of stripping all strings in a 
collection seems to be a rather esoteric case.  Remember that there can 
be any type of object in such a collection!  When deciding on adding 
something to a core class you should look at the outside.

> Anyway, my question is - is it true that new methods are rarely added to
> ruby?

Do you mean by the core team or ad hoc by application programmers? 
Modification of core classes is done cautiously (seldom) while 
application programmers seem to often augment core classes with 
additional methods.

> The String class is really rather big compared to the Array class, and i
> figured that people will work with string objects most of the time

This totally depends on the application case.  Side note: my impression 
is that people tend to create too few classes (common example: methods 
are added to Hash instead of creating a class whose instances contain a 
Hash instance and use it appropriately).

> (compared to Array objects or Hash objects) - they are useful, but I
> think all through rubyland (think all virtual ruby objects), there would
> be more string objects than array objects etc..

I am not sure I get your point.  The sole fact that there are more 
instances of class X vs. class Y does not tell me anything about what 
methods should be added to X or Y.

Kind regards

	robert