Use if instead of case

This commit is contained in:
David Rueck
2013-10-17 16:18:56 -07:00
parent fc762befcc
commit a4e69dea6b
+4 -6
View File
@@ -894,18 +894,16 @@ defmodule String do
def slice(string, Range[first: first, last: last]) when first < 0 and last >= 0 do
real_first = do_length(next_grapheme(string)) - abs(first)
case real_first >= 0 do
true -> do_slice(next_grapheme(string), real_first, last, 0, "")
false -> nil
if real_first >= 0 do
do_slice(next_grapheme(string), real_first, last, 0, "")
end
end
def slice(string, Range[first: first, last: last]) when first < 0 and last < 0 do
real_first = do_length(next_grapheme(string)) - abs(first)
real_last = do_length(next_grapheme(string)) - abs(last)
case real_first >= 0 do
true -> do_slice(next_grapheme(string), real_first, real_last, 0, "")
false -> nil
if real_first >= 0 do
do_slice(next_grapheme(string), real_first, real_last, 0, "")
end
end