You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lib/elixir/pages/getting-started/sigils.md
+3-7Lines changed: 3 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -91,7 +91,7 @@ iex> ~w(foo bar bat)a
91
91
92
92
## Interpolation and escaping in textual sigils
93
93
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:
95
95
96
96
```elixir
97
97
iex>~s(String with escape codes \x26#{"inter"<>"polation"})
@@ -117,8 +117,6 @@ The following escape codes can be used in textual sigils:
117
117
*`\xDD` - represents a single byte in hexadecimal (such as `\x13`)
118
118
*`\uDDDD` and `\u{D...}` - represents a Unicode codepoint in hexadecimal (such as `\u{1F600}`)
119
119
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
-
122
120
Sigils also support heredocs, that is, three double-quotes or single-quotes as separators:
123
121
124
122
```elixir
@@ -160,7 +158,7 @@ def convert(...)
160
158
161
159
## Calendar sigils
162
160
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.
164
162
165
163
### Date
166
164
@@ -240,6 +238,4 @@ iex> ~i(42)n
240
238
-42
241
239
```
242
240
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