Skip to content

End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Enumerable#reverse_each

enum.reverse_each(*args) { |item| block } → enum
enum.reverse_each(*args) → an_enumerator

Builds a temporary array and traverses that array in reverse order.

If no block is given, an enumerator is returned instead.

Example
(1..3).reverse_each { |v| p v }

produces:

Example
3
2
1
See also #reject #select #reduce #slice_after also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.1