Use extra functions and stop using downcase array.

This commit is contained in:
2018-12-05 15:58:46 -08:00
parent a24b176417
commit 24c93c7a63
2 changed files with 24 additions and 5 deletions

View File

@@ -20,3 +20,25 @@ class Rectangle
end
end
end
class String
def select(&block)
String.build do |s|
each_char do |c|
s << c if yield c
end
end
end
def select!(&block)
i = 0
s = size
while i < s
if yield [i]
i += 1
else
s -= 1
end
end
end
end