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/binaries-strings-and-charlists.md
+10-4Lines changed: 10 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -239,8 +239,7 @@ iex> [?h, ?e, ?l, ?l, ?o]
239
239
~c"hello"
240
240
```
241
241
242
-
The `~c` sigil (we'll cover sigils later in the ["Sigils"](sigils.md) chapter)
243
-
indicates the fact that we are dealing with a charlist and not a regular string.
242
+
The `~c` sigil (we'll cover sigils later in the ["Sigils"](sigils.md) chapter) indicates the fact that we are dealing with a charlist and not a regular string.
244
243
245
244
Instead of containing bytes, a charlist contains integer code points. However, the list is only printed as a sigil if all code points are within the ASCII range:
Furthermore, you can convert a charlist to a string and back by using the `to_string/1` and `to_charlist/1`:
262
268
263
269
```elixir
264
270
iex>to_charlist("hełło")
@@ -271,7 +277,7 @@ iex> to_string(1)
271
277
"1"
272
278
```
273
279
274
-
Note that those functions are polymorphic - not only do they convert charlists to strings, they also operate on integers, atoms, and so on.
280
+
The functions above are polymorphic, in other words, they accept many shapes: not only do they convert charlists to strings (and vice-versa), they can also convert integers, atoms, and so on.
275
281
276
282
String (binary) concatenation uses the `<>` operator but charlists, being lists, use the list concatenation operator `++`:
0 commit comments