Skip to content

Commit 6f5bedc

Browse files
committed
Merge pull request #3747 from eksperimental/correct_arg_name
String: Rename args "str" to "string"
2 parents 912c461 + 64a3190 commit 6f5bedc

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

lib/elixir/lib/string.ex

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,7 @@ defmodule String do
833833
defdelegate next_codepoint(string), to: String.Unicode
834834

835835
@doc ~S"""
836-
Checks whether `str` contains only valid characters.
836+
Checks whether `string` contains only valid characters.
837837
838838
## Examples
839839
@@ -927,20 +927,20 @@ defmodule String do
927927

928928
def chunk("", _), do: []
929929

930-
def chunk(str, trait) when trait in [:valid, :printable] do
931-
{cp, _} = next_codepoint(str)
930+
def chunk(string, trait) when trait in [:valid, :printable] do
931+
{cp, _} = next_codepoint(string)
932932
pred_fn = make_chunk_pred(trait)
933-
do_chunk(str, pred_fn.(cp), pred_fn)
933+
do_chunk(string, pred_fn.(cp), pred_fn)
934934
end
935935

936-
defp do_chunk(str, flag, pred_fn), do: do_chunk(str, [], <<>>, flag, pred_fn)
936+
defp do_chunk(string, flag, pred_fn), do: do_chunk(string, [], <<>>, flag, pred_fn)
937937

938938
defp do_chunk(<<>>, acc, <<>>, _, _), do: Enum.reverse(acc)
939939

940940
defp do_chunk(<<>>, acc, chunk, _, _), do: Enum.reverse(acc, [chunk])
941941

942-
defp do_chunk(str, acc, chunk, flag, pred_fn) do
943-
{cp, rest} = next_codepoint(str)
942+
defp do_chunk(string, acc, chunk, flag, pred_fn) do
943+
{cp, rest} = next_codepoint(string)
944944
if pred_fn.(cp) != flag do
945945
do_chunk(rest, [chunk|acc], cp, not flag, pred_fn)
946946
else
@@ -1523,7 +1523,7 @@ defmodule String do
15231523
@doc """
15241524
Returns a float value between 0 (equates to no similarity) and 1 (is an exact match)
15251525
representing [Jaro](https://en.wikipedia.org/wiki/Jaro–Winkler_distance)
1526-
distance between `str1` and `str2`.
1526+
distance between `string1` and `string2`.
15271527
15281528
The Jaro distance metric is designed and best suited for short strings such as person names.
15291529
@@ -1537,15 +1537,15 @@ defmodule String do
15371537
"""
15381538

15391539
@spec jaro_distance(t, t) :: 0..1
1540-
def jaro_distance(str1, str2)
1540+
def jaro_distance(string1, string2)
15411541

1542-
def jaro_distance(str, str), do: 1.0
1543-
def jaro_distance(_str, ""), do: 0.0
1544-
def jaro_distance("", _str), do: 0.0
1542+
def jaro_distance(string, string), do: 1.0
1543+
def jaro_distance(_string, ""), do: 0.0
1544+
def jaro_distance("", _string), do: 0.0
15451545

1546-
def jaro_distance(str1, str2) do
1547-
{chars1, len1} = decompose(str1)
1548-
{chars2, len2} = decompose(str2)
1546+
def jaro_distance(string1, string2) do
1547+
{chars1, len1} = decompose(string1)
1548+
{chars2, len2} = decompose(string2)
15491549

15501550
case match(chars1, len1, chars2, len2) do
15511551
{0, _trans} -> 0.0
@@ -1557,8 +1557,8 @@ defmodule String do
15571557
end
15581558

15591559
@compile {:inline, decompose: 1}
1560-
defp decompose(str) do
1561-
chars = graphemes(str)
1560+
defp decompose(string) do
1561+
chars = graphemes(string)
15621562
{chars, Kernel.length(chars)}
15631563
end
15641564

0 commit comments

Comments
 (0)