Write a Ruby program to iterate an array starting from the last element.
nums = [10, 20, 30, 40, 10, 10, 20] print "Original array:\n" print nums print "\nReverse array:\n" nums.reverse.each { |x| puts x }
Output:
Original array: [10, 20, 30, 40, 10, 10, 20] Reverse array: 20 10 10 40 30 20 10
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Output:
need an explanation for this answer? contact us directly to get an explanation for this answer