From: "Aleksi Niemelä" Date: 2000-07-03T19:29:27+02:00 Subject: [ruby-talk:03771] Re: Array.uniq! returning nil > |Why Array.uniq! returns nil if it doesn't do anything (every element > |is unique). Same for Array.compact! Next example requires two times > |the memory what uniq! -version would. Could be a problem > with large texts. > > Ruby 1.5.x do the magic for you. Non bang methods don't copy memory > regions unless copying is really needed, using the state-of-the-art > copy-on-write technology. ;-) That's good. *Waiting eagerly* :). But even then I guess uniqChars = text.split(//).uniq needs a copy if there're any characters to be removed from the array. And if we can't rely on that fact there are always some chars to be removed, it seems we can't use Array.uniq!. It's all ok, I can always write chars = text.split(//) chars.uniq! uniqChars = chars What bothers me is that it takes one temporary variable (or not, if you allow misleading variable names :), two extra lines (or one) thus harder to read, and most of all, I have to remember uniq! could return nil, and code accordingly. And that uniq is not equivalent for dup.uniq!. - Aleksi