Ruby/Array/reverse each

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск

Reverse each with array

a = ["a","b","c"]
a.reverse_each {|e| print e}       # Array-specific: prints "cba"



Reverse from backend with reverse_each

[1, 2, 3, 4].reverse_each { |x| puts x }
# 4
# 3
# 2
# 1