[erlang-questions] Which is best? string:concat or ++?
Mon May 7 16:12:45 CEST 2012
On Mon, May 7, 2012 at 7:31 AM, Paul Barry <> wrote:
> Hi folks.
> This might be a case of a dumb question, but here goes anyway. :-)
> I have two strings, A and B. Is it better to use:
> string:concat(A, B)
> A ++ B
> when combining them to create a new string? I'm writing some code
> that generates a chunk of HTML. I know that using ++ on big lists is
> regarded as a "no-no", but is it acceptable here?
You may want to consider, if possible, to move all your string
operations to binary format.
A = <<"<html><head><title>">>.
B = <<"My Title">>.
C = <<"</title></head><body>hi</body></html>">>.
All = <<A/binary, B/binary, C/binary>>.
The All part could just be a return from a fun, etc.
More information about the erlang-questions