Skip to content

Commit 1ccb7a1

Browse files
authored
Explicitly mention trimming in String.split/1 doc (#13802)
1 parent 00f2662 commit 1ccb7a1

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/elixir/lib/string.ex

+9-3
Original file line numberDiff line numberDiff line change
@@ -357,9 +357,10 @@ defmodule String do
357357

358358
@doc ~S"""
359359
Divides a string into substrings at each Unicode whitespace
360-
occurrence with leading and trailing whitespace ignored. Groups
361-
of whitespace are treated as a single occurrence. Divisions do
362-
not occur on non-breaking whitespace.
360+
occurrence with leading and trailing whitespace ignored.
361+
362+
Groups of whitespace are treated as a single occurrence.
363+
Divisions do not occur on non-breaking whitespace.
363364
364365
## Examples
365366
@@ -375,6 +376,11 @@ defmodule String do
375376
iex> String.split("no\u00a0break")
376377
["no\u00a0break"]
377378
379+
Removes empty strings, like when using `trim: true` in `String.split/3`.
380+
381+
iex> String.split(" ")
382+
[]
383+
378384
"""
379385
@spec split(t) :: [t]
380386
defdelegate split(binary), to: String.Break

0 commit comments

Comments
 (0)