From fa627f094864f07001663fd075b3778bd3b648e2 Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Fri, 15 Sep 2017 01:43:32 -0700 Subject: [PATCH] Mention multi-line strings in the syntax reference (#6572) --- lib/elixir/pages/Syntax Reference.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/lib/elixir/pages/Syntax Reference.md b/lib/elixir/pages/Syntax Reference.md index 42055e5591..8d356cc918 100644 --- a/lib/elixir/pages/Syntax Reference.md +++ b/lib/elixir/pages/Syntax Reference.md @@ -31,7 +31,26 @@ If the colon is followed by a double- or single-quote, the atom can be made of a ### Strings -Strings in Elixir are written between double-quotes, such as `"foo"`. Any double-quote inside the string must be escaped with `\ `. Strings support Unicode characters and are stored in UTF-8 encoding. +Single-line strings in Elixir are written between double-quotes, such as `"foo"`. Any double-quote inside the string must be escaped with `\ `. Strings support Unicode characters and are stored as UTF-8 encoded binaries. + +Multi-line strings in Elixir are written with three double-quotes, and can have unescaped quotes within them. The resulting string will end with a newline. The indentation of the last `"""` is used to strip indentation from the inner string. For example: + +``` +iex> test = """ +...> this +...> is +...> a +...> test +...> """ +" this\n is\n a\n test\n" +iex> test = """ +...> This +...> Is +...> A +...> Test +...> """ +"This\nIs\nA\nTest\n" +``` Strings are always represented as themselves in the AST. @@ -39,6 +58,8 @@ Strings are always represented as themselves in the AST. Charlists in Elixir are written in single-quotes, such as `'foo'`. Any single-quote inside the string must be escaped with `\ `. Charlists are a list of integers, each integer representing a Unicode character. +Multi-line charlists are written with three single-quotes (`'''`), the same multi-line strings are. + Charlists are always represented as themselves in the AST. ### Lists, tuples and binaries