May 2018
Intermediate to advanced
412 pages
9h 3m
English
Elixir has two kinds of string: single-quoted and double-quoted. They differ significantly in their internal representation. But they also have many things in common.
Strings can hold characters in UTF-8 encoding.
They may contain escape sequences:
\a | BEL (0x07) | \b | BS (0x08) | \d | DEL (0x7f) |
\e | ESC (0x1b) | \f | FF (0x0c) | \n | NL (0x0a) |
\r | CR (0x0d) | \s | SP (0x20) | \t | TAB (0x09) |
\v | VT (0x0b) | \uhhh | 1–6 hex digits | \xhh | 2 hex digits |
They allow interpolation on Elixir expressions using the syntax #{...}:
| | iex> name = "dave" |
| | "dave" |
| | iex> "Hello, #{String.capitalize name}!" |
| | "Hello, Dave!" |
Characters that would otherwise have special meaning can be escaped with a backslash.
They support heredocs.
Any string can span several lines. To illustrate this, ...
Read now
Unlock full access