From: "Peña, Botp" Date: 2002-12-09T12:17:52+09:00 Subject: Re: [YANQ] -yet another (ruby) newbie question -string#concat Hi sir David (aka dblack@candle.superlink.net [mailto:dblack@candle.superlink.net]): You replied last Monday, December 09, 2002 10:43 AM: > >Hello Ruby Friends, > > >From now on, I'll prefix my questions w YANQ (yet another (ruby) newbie > > question) so it would be easier for you to delete (in case :-). >ruby + newbie =3D=3D nuby :-) ooops. Then that should be yet another nuby question. Many thanks, sir David :-) >> My YANQotd is regarding string#concat. A sample code and output would be >> good to illustrate: >> >> C:\family\ruby>type a1.rb >> fn =3D "bot" >> ln =3D "pen" >> name =3D fn.concat(ln) >> >> print "first name: ", fn >> puts >> print "last name : ", ln >> puts >> print "full name : ", name >> >> C:\family\ruby>ruby a1.rb >> first name: botpen >> last name : pen >> full name : botpen >> >> >> I noticed that concat modified fn. I looked for other concat methods but >> couldn't find one (but the + op). I was hoping that there would be a conc= at! > >and concat pair (like chop!/chop and chomp!/chomp). >> >> Maybe string#concat! was deprecated for "+"? My concern is that (as a >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. Yes, sir David, I'll be using string#+ now. >> newbie), I'm trying to avoid methods with "!" (like chomp!/chop!) so I ha= ve >> less to worry/know. My strategy was working and I was actually coding w >> breeze... until I bump.. :-( >I think in the long run that strategy will give you *more* to worry >about :-) Don't feel you have to avoid ! methods; they're a normal >part of Ruby, and not particularly complicated. I will try not avoiding ! methods later, sir David... Anyway, it's just this little bump that I tripped on :-) >David Many thanks. Kind regards, -botp