From: "Peña, Botp" Date: 2004-05-28T15:49:15+09:00 Subject: Re: Nasty string growth performance Joel VanderWerf [mailto:vjoel@PATH.Berkeley.EDU] wrote: > Tom Trebisky wrote: > > buf = "" > ... > > buf += line > > and > > > buf = Array.new > ... > > buf.push line > > are not comparable constructs. > > The first one is the same as > > buf = buf + line > > which constructs a new string each time. The second one modifies the > existing array in place, which is why you saw better performance. > > What you probably want is > > buf << line > > This just concatenates line on the end of the buf string, > modifying buf > in place. Forgive my ignorance, but may I know the reason why buf += line was made to act different from buf << line Of course, I prefer the syntax of the former w the behavior of the latter. It's commonplace (for nubies ie :). kind regards -botp