From: Hal Fulton Date: 2003-08-27T05:52:06+09:00 Subject: Re: Array#uniq! Mark Wilson wrote: > 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. [snippage] > 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. I've thought about these issues, too... I usd to be bitten frequently by the nil-return bug^H^H^H feature. But then I just fell out of the habit of chaining certain methods. I never use the fact that they return nil. On the other hand, the add? method seems a little unintuitive to me... in principle I like it OK, but it is a little unusual that a ?-method changes its receiver. I don't know anywhere else that happens. I once suggested as a joke four other suffixes: !!, ??, ?!, and !?. But the last of these is looking slightly more serious and less of a joke now. But no, I'm not seriously proposing it. Who would use a language feature like !? on a method name? Cheers, Hal