From bc9adf458ff0134556ac5e52d16364467376704b Mon Sep 17 00:00:00 2001 From: sabiwara Date: Sun, 1 Sep 2024 11:15:13 +0900 Subject: [PATCH 1/2] Explicitly mention trimming in String.split/1 doc --- lib/elixir/lib/string.ex | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/elixir/lib/string.ex b/lib/elixir/lib/string.ex index 12a96912142..8e318739b7c 100644 --- a/lib/elixir/lib/string.ex +++ b/lib/elixir/lib/string.ex @@ -375,6 +375,11 @@ defmodule String do iex> String.split("no\u00a0break") ["no\u00a0break"] + Removes empty strings, like when using `trim: true` in `String.split/3`. + + iex> String.split(" ") + [] + """ @spec split(t) :: [t] defdelegate split(binary), to: String.Break From 92523005509d83fc7cc9bc952d05d8ca829a4c0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Sun, 1 Sep 2024 04:20:29 +0200 Subject: [PATCH 2/2] Update string.ex --- lib/elixir/lib/string.ex | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/elixir/lib/string.ex b/lib/elixir/lib/string.ex index 8e318739b7c..7f76063bd5a 100644 --- a/lib/elixir/lib/string.ex +++ b/lib/elixir/lib/string.ex @@ -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