Strings and Character Lists
Explore the fundamental differences between Elixir strings and character lists. Understand how double-quoted strings differ from single-quoted character lists, their internal representations, and how to work with them using pattern matching and list functions.
We'll cover the following...
Before we get further into this, we need to explain something. In most other languages, we’d call both 'cat' and "cat" strings. And that’s what we’ve been doing so far. But Elixir has a different convention.
In Elixir, the convention is that we call it a string only if it’s double-quoted, like “strings”. The single-quoted form is a character list.
This is important. The single- and double-quoted forms are very different, and libraries that work on strings work only on the double-quoted form.
Let’s explore the ...