Strings

Strictly speaking, there are no strings in Erlang. To represent a string in Erlang, we can choose between representing the string as a list of integers or as a binary (for a discussion of binaries, see Binaries). When a string is represented as a list of integers, each element in the list represents a Unicode codepoint.

We can create such a list by using a string literal. A string literal is just a sequence of characters enclosed in double quotation marks ("), so, for example, we can write this:

 
1>​ Name = "Hello".
 
"Hello"

"Hello" is just shorthand for the list of integer character codes that represent the individual characters in that string.

Note: In some programming languages, strings can be quoted with either single or double ...

Get Programming Erlang, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.