From: Mathieu Bouchard Date: 2005-03-21T08:30:23+09:00 Subject: Re: strip and its evil brother strip! On Sun, 20 Mar 2005, Daniel Amelang wrote: > I ranted about this very behavior 2 days ago. I'm willing to do an RCR > if anyone agrees (hint, hint). > http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/133894 One thing I dislike about the Smalltalk-style habit of returning self when there is otherwise no return value, is that this return value is something you already have, and it gets in the way of ex-post-facto extending your interface by making the method return a meaningful value. In the case of Ruby, the return value is essentially a boolean telling you whether any modifications had to be done, but somehow, instead of using true vs false, it's self vs nil. I don't know why. Smalltalk also has an alternate mechanism at the syntax level, for making several methodcalls to a receiver written only once. This makes returning self sound even stupider to me in that context. I wish Ruby had a similar feature so that methods never have to return systematically self and so whenever such a thread appears we could point people to that feature. Example (with some extra spaces inserted, and supposing there are methods named like that in Smalltalk) Smalltalk: x chop strip. Ruby: x.chop! .strip! Smalltalk: x chop. x strip. Ruby: x.chop!; x.strip! Smalltalk: x chop; strip. Ruby (no equivalent) In the last version, x is only mentioned once, and the return value of chop is discarded. I think it could be nice to have something like that in Ruby. _____________________________________________________________________ Mathieu Bouchard -=- Montr�al QC Canada -=- http://artengine.ca/matju