From: "Aleksi Niemelä" Date: 2000-07-04T15:23:15+02:00 Subject: [ruby-talk:03795] Re: Array.uniq! returning nil > As matz said in [ruby-talk:3785] and Dave said in [ruby-talk:1229], > I often want to check if modification is done. These and your example was exactly what I was looking for! Thank you. Now I've come up with another proposition. We could change the behaviour in next versions. (And of course provide a simple, yet most cases fixing upgrade script.) We could define obj.method! to *always* return the possibly altered object. And, now the new trick, add Array.uniq!? which would work like current Array.uniq!. The actual semantic hint the developer should get when he sees obj.method!? is 'this method modifies the object and returns something (possibly boolean) describing if any action was taken'. In Array.uniq!? case we could return nil when the array was unchanged and the modified array if it changed. (Or we could return array consisting of removed items (items which had a duplicate), which is subject for another debate. Which I could kill now by saying if one needs the array of items which had duplicate on the original array he could say: array.dup - array.uniq! I might be carrying method?:=$-冠 -notation too far here, but as you see we have still plenty of ugly characters left for use :). Besides, this didn't use any more ugly characters, it just combined old ones. - Aleksi