[erlang-questions] Question re io:format and string handling

Ulf Wiger (TN/EAB) ulf.wiger@REDACTED
Fri Oct 17 16:57:56 CEST 2008

Robert Virding skrev:
> - A more direct but less general way is to concatenate the string directly:
> Cat = "cat",
> Hat = "hat",
> Phrase = "The " ++ Cat ++ " in the " ++ Hat

Or, if the string is going to be sent out through a port
right away, and you don't care if it isn't flat:

Phrase = ["The ", Cat, " in the ", Hat]

(The deep string gets flattened when passed through
a port. This is quite useful when constructing e.g.
a web page or large XML structure.)

Ulf W

More information about the erlang-questions mailing list