Skip to content

Explicitly mention trimming in String.split/1 doc #13802

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions lib/elixir/lib/string.ex
Original file line number Diff line number Diff line change
Expand Up @@ -357,9 +357,10 @@ defmodule String do

@doc ~S"""
Divides a string into substrings at each Unicode whitespace
occurrence with leading and trailing whitespace ignored. Groups
of whitespace are treated as a single occurrence. Divisions do
not occur on non-breaking whitespace.
occurrence with leading and trailing whitespace ignored.

Groups of whitespace are treated as a single occurrence.
Divisions do not occur on non-breaking whitespace.

## Examples

Expand All @@ -375,6 +376,11 @@ defmodule String do
iex> String.split("no\u00a0break")
["no\u00a0break"]

Removes empty strings, like when using `trim: true` in `String.split/3`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Removes empty strings, like when using `trim: true` in `String.split/3`.
This function removes empty strings, similar to `trim: true` in `String.split/3`.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think English prefers the sentence subject to be explicit most times. :)


iex> String.split(" ")
[]

"""
@spec split(t) :: [t]
defdelegate split(binary), to: String.Break
Expand Down
Loading