mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
Fix method name
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user