[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Newbie question

ed

7/24/2007 8:37:00 PM

Hi,

Under most languages it pays to use a StringBuffer of sorts.

Is this true for Ruby, should one use a StringBuffer when appending
many strings?

If so, what is the string buffer called for Ruby?

--
The PRI to the demarc is dropping packets because of a translator who
speaks Bocce. RedHat is going bankrupt.
:: http://ww... :: http://ww...gpg
4 Answers

Marcel Molina Jr.

7/24/2007 8:43:00 PM

0

On Wed, Jul 25, 2007 at 05:40:01AM +0900, ed wrote:

> Under most languages it pays to use a StringBuffer of sorts.
>
> Is this true for Ruby, should one use a StringBuffer when appending
> many strings?
>
> If so, what is the string buffer called for Ruby?

Strings are mutable in ruby so you just use the << method to append to a
string. Don't, though, use + as that creates a new string.

'Foo' << 'Bar', etc

marcel
--
Marcel Molina Jr. <marcel@vernix.org>

Harold Hausman

7/24/2007 8:48:00 PM

0

On 7/24/07, ed <ed@noreply.com> wrote:
> Hi,
>
> Under most languages it pays to use a StringBuffer of sorts.
>

Under most languages it pays to not do heinous things that cause the
interpreter/runtime to thrash.

Knowledge is power:
http://whytheluckystiff.net/articles/theFullyUpturn...

hth,
-Harold

ed

7/24/2007 8:55:00 PM

0

On Wed, 25 Jul 2007 05:47:43 +0900
"Harold Hausman" <hhausman@gmail.com> wrote:

> On 7/24/07, ed <ed@noreply.com> wrote:
> > Hi,
> >
> > Under most languages it pays to use a StringBuffer of sorts.
> >
>
> Under most languages it pays to not do heinous things that cause the
> interpreter/runtime to thrash.
>
> Knowledge is power:
> http://whytheluckystiff.net/articles/theFullyUpturn...

Thanks very much, this looks like a very useful resource.

--
The 2400 Baud Modem to www.instenes.com is bullshitting like Bob Grant
because of the terrible acting by the kid who played anakin. Earthlink
is wished well in their future endeavors. :: http://ww... ::
http://ww...gpg

ed

7/24/2007 8:56:00 PM

0

On Wed, 25 Jul 2007 05:43:22 +0900
"Marcel Molina Jr." <marcel@vernix.org> wrote:

> On Wed, Jul 25, 2007 at 05:40:01AM +0900, ed wrote:
>
> > Under most languages it pays to use a StringBuffer of sorts.
> >
> > Is this true for Ruby, should one use a StringBuffer when appending
> > many strings?
> >
> > If so, what is the string buffer called for Ruby?
>
> Strings are mutable in ruby so you just use the << method to append
> to a string. Don't, though, use + as that creates a new string.
>
> 'Foo' << 'Bar', etc

Thanks, I will give that a go. My automatic knee-jerk reaction was to
use +=, as you pointed out, looks like some more syntax to adjust to
here!

--
The dirt trail to the DVD player is rup'n like a mofo because of Tom
Cullen saying M-O-O-N spells network outtage. The Script Kiddy is
practising the jedi mind trick. :: http://ww... ::
http://ww...gpg