Merge pull request #1981 from k-tsj/fix-method-name

Fix method name in Array#reverse_each
This commit is contained in:
Yukihiro "Matz" Matsumoto
2014-03-30 18:44:38 +09:00
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