Skip to content

Commit 9ebe851

Browse files
jsvisaJosé Valim
authored andcommitted
Fix String.slice error
iex(76)> String.slice("string", 0..-2) nil # you see here is the issue, it shouldn't return `nil` iex(77)> String.slice("string", 1..-2) "trin" iex(78)> String.slice("string", -5..-2) "trin"
1 parent cb81c6b commit 9ebe851

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/elixir/lib/string.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ defmodule String do
913913
last = total + last
914914
end
915915

916-
if first > 0 do
916+
if first >= 0 do
917917
do_slice(next_grapheme(string), first, last, 0, "")
918918
end
919919
end

0 commit comments

Comments
 (0)