Newbie question

E

ed

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?
 
M

Marcel Molina Jr.

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
 
E

ed

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!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,263
Messages
2,571,312
Members
47,988
Latest member
HarryBeck

Latest Threads

Top