Fix method name

This commit is contained in:
Kazuki Tsujimoto
2014-03-30 18:32:19 +09:00
parent b1eef40630
commit 01a798362f
2 changed files with 11 additions and 1 deletions
+1 -1
View File
@@ -204,7 +204,7 @@ class Array
# for efficiency
def reverse_each(&block)
return to_enum :sort_by unless block_given?
return to_enum :reverse_each unless block_given?
i = self.size - 1
while i>=0
+10
View File
@@ -131,3 +131,13 @@ assert("Array#fill") do
assert_equal [1, 2, 3, 27], a.fill(0..1) { |i| i+1 }
assert_raise(ArgumentError) { a.fill }
end
assert("Array#reverse_each") do
a = [ "a", "b", "c", "d" ]
b = []
a.reverse_each do |i|
b << i
end
assert_equal [ "d", "c", "b", "a" ], b
assert_equal [ "d", "c", "b", "a" ], a.reverse_each.to_a
end