From: Gavin Sinclair Date: 2002-12-09T12:26:54+09:00 Subject: Re: [YANQ] -yet another (ruby) newbie question -string#concat From: "Mike Campbell" > > > String#concat is a synonym for String#<<, and since it modifies the > > object, a concat! version wouldn't make sense. You can indeed use > > String#+ if you want to create a new string instead of modifying the > > old one. > > To be fair here, it might be argued that the String#concat alias is misnamed and > *IT* doesn't make sense, given what it does. Seems to me (and I'm guessing > Botp) that the alias SHOULD be String#concat!. I'd agree with that, FWIW. IMO, botp's confusion is quite understandable. I never use #concat, but if I did I'm sure I would have raised this issue before. 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). 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. I wonder how much existing code such a change will break. After all, who, in a published program or library, would use #concat ? :) Cheers, Gavin