Skip to content

Commit ec8156a

Browse files
committed
Tiny cleanup on sigil chapter
1 parent 7967ff9 commit ec8156a

1 file changed

Lines changed: 3 additions & 7 deletions

File tree

lib/elixir/pages/getting-started/sigils.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ iex> ~w(foo bar bat)a
9191

9292
## Interpolation and escaping in textual sigils
9393

94-
Elixir supports some sigil variants to deal with escaping characters and interpolation. In particular, uppercase-letter textual sigils do not perform interpolation nor escaping. For example, although both `~s` and `~S` will return strings, the former allows escape codes and interpolation while the latter does not:
94+
Sigils also help deal with escaping characters and interpolation. In particular, uppercase-letter textual sigils do not perform interpolation nor escaping, and most lowercase sigils have an uppercase variant. For example, although both `~s` and `~S` will return strings, the former allows escape codes and interpolation while the latter does not:
9595

9696
```elixir
9797
iex> ~s(String with escape codes \x26 #{"inter" <> "polation"})
@@ -117,8 +117,6 @@ The following escape codes can be used in textual sigils:
117117
* `\xDD` - represents a single byte in hexadecimal (such as `\x13`)
118118
* `\uDDDD` and `\u{D...}` - represents a Unicode codepoint in hexadecimal (such as `\u{1F600}`)
119119

120-
In addition to those, a double quote inside a double-quoted string needs to be escaped as `\"`, and, analogously, a single quote inside a single-quoted char list needs to be escaped as `\'`. Nevertheless, it is better style to change delimiters as seen above than to escape them.
121-
122120
Sigils also support heredocs, that is, three double-quotes or single-quotes as separators:
123121

124122
```elixir
@@ -160,7 +158,7 @@ def convert(...)
160158

161159
## Calendar sigils
162160

163-
Elixir offers several sigils to deal with various flavors of times and dates.
161+
Elixir offers sigils to deal with various flavors of times and dates.
164162

165163
### Date
166164

@@ -240,6 +238,4 @@ iex> ~i(42)n
240238
-42
241239
```
242240
243-
Custom sigils may be either a single lowercase character, or an uppercase character followed by more uppercase characters and digits.
244-
245-
Sigils can also be used to do compile-time work with the help of macros. For example, regular expressions in Elixir are compiled into an efficient representation during compilation of the source code, therefore skipping this step at runtime. If you're interested in the subject, you can learn more about macros and check out how sigils are implemented in the `Kernel` module (where the `sigil_*` functions are defined).
241+
Custom sigils may be either a single lowercase character, or an uppercase character followed by more uppercase characters and digits. In practice, they are often used to embed templating languages or even represent regular languages within Elixir itself. If you're interested in learning more, check out how sigils are implemented in the `Kernel` module (where the `sigil_*` functions/macros are defined) for a starting point.

0 commit comments

Comments
 (0)