Skip to content

Commit 11c4c27

Browse files
author
José Valim
committed
Add guards to lstrip and rstrip
1 parent 4051cf5 commit 11c4c27

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/elixir/lib/string.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ defmodule String do
333333
end
334334
end
335335

336-
def rstrip(string, char) do
336+
def rstrip(string, char) when is_integer(char) do
337337
do_rstrip(string, "", char)
338338
end
339339

@@ -373,11 +373,11 @@ defmodule String do
373373

374374
@spec lstrip(t, char) :: t
375375

376-
def lstrip(<<char :: utf8, rest :: binary>>, char) do
376+
def lstrip(<<char :: utf8, rest :: binary>>, char) when is_integer(char) do
377377
<<lstrip(rest, char) :: binary>>
378378
end
379379

380-
def lstrip(other, _char) do
380+
def lstrip(other, char) when is_integer(char) do
381381
other
382382
end
383383

0 commit comments

Comments
 (0)