From: matz@... (Yukihiro Matsumoto) Date: 2003-02-14T10:15:52+09:00 Subject: Re: Why does Array#compact! return the array, but uniq! return a count? Hi, In message "Re: Why does Array#compact! return the array, but uniq! return a count?" on 03/02/13, Tom Payne writes: |> Array's bang methods return nil if it does not modify the receiver, so |> that chaining is not encouraged. | |I'm not suggesting a change, but what is the rationale for this? Because their's no cheaper way to detect modifies, without making copies. |IMHO, chaining is one of the most useful aspects of ruby -- multiple |lines of code can be folded into one. With chaining you're generally |not interested in the intermediate results (otherwise you'd store them |in a variable somewhere) and so in-place modification is more |efficient since you don't have to create lots of intermediate objects |that are then immediately discarded. Use non-bang methods (bit slower, but safer) for chaining. Ugly bangs are warning mark for side effects. matz.