Strings and Character Lists
Learn how single-quoted strings work differently in Elixir.
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 ...