From: Mark Wilson Date: 2003-08-27T05:10:10+09:00 Subject: Re: Array#uniq! I've thought about this for awhile and had on my to do list a catalog of how container objects respond to various methods that are meant to change the contents of the container. The inspiration for these thoughts is the implementation in the set class, where the default is to return the object whether or not the method modified the contents of the container. If one wants to know whether the modification occurred, one calls the method with a question mark appended. For example Set#add(object) will add the object if it does not exist in the set and return the modified set. If the object is in the set, it is not added and the set is returned. Set#add?(object) will add the object if not already present and return 'nil' if the object is already present. The array class provides similar functionality for the nil case for at least one method (Array#delete), but uses a block rather than a question mark. Array#delete(object) returns nil if the object is not in the array and returns the deleted object if it is in the array. However, if a block is used, the block is executed if the object is not in the array. For example, a = Array.new(1, 2, 3, 4, 5) a.delete(6) { a } returns the array [1, 2, 3, 4, 5]. I don't know whether or how these method returns should be changed, but I do think the topic is worth further thought and discussion. Regards, Mark