From: dblack@... Date: 2002-12-09T12:47:16+09:00 Subject: Re: [YANQ] -yet another (ruby) newbie question -string#concat Hi -- On Mon, 9 Dec 2002, Gavin Sinclair wrote: > I see no reason why str1.concat(str2) should modify str1, any more than the > Unix command "cat file1 file2" should modify file1 (it doesn't). But the semantics are very different. The Unix semantics are very "top level", looking down equally at both files. Moreover, one could argue that the "receiver" here is STDOUT, which is indeed being modified. > The Mirriam-Webster online dictionary lists "concatenate [v.t.]" as > > to link together in a series or chain > > This suggests that String#concat should indeed be destruvtive. However, since > there is ample room for confusion, and there are many String#xxx! methods, I > conclude that the ideal solution is for String to have the following methods: > > String#concat > String#concat! > > with their operations being (now) obvious. Or not :-) String#concat! sounds redundant to me (see my other post). > I wonder how much existing code such a change will break. After > all, who, in a published program or library, would use #concat ? :) /usr/local/src/ruby$ grep \\.concat `find . -name "*.rb"` | wc -l 43 (Of course some of those are Array#concat, but a lot are strings.) David -- David Alan Black home: dblack@candle.superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav