From: Robert Dober Date: 2006-06-22T04:23:34+09:00 Subject: Re: The difference between s=s+”a” ans s<< ”a” ------=_Part_76677_17863094.1150917812588 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 6/21/06, Alan Moen wrote: > > Hi, > > I wonder what is the difference between s=3Ds+"a" ans s<< "a"? s =3D s + "a" (1) compute a new String object "s" + a (2) set s as a reference to the newly created object s<<"a" (1) append "a" to the String object s refers to. The latter is much faster and should be prefered when possible (it will not be possible if s is frozen e.g.) Cheers Robert Somebody told me that s<< "a" concatenates the string without mutation. > Is that right? > > Thanks, > Alan > > -- > Posted via http://www.ruby-forum.com/. > > --=20 Deux choses sont infinies : l'univers et la b=EAtise humaine ; en ce qui concerne l'univers, je n'en ai pas acquis la certitude absolue. - Albert Einstein ------=_Part_76677_17863094.1150917812588--