This page contains automated test results for code from O'Reilly's Ruby Cookbook. If this code looks interesting or useful, you might want to buy the whole book.
Reversing an Array | ||
---|---|---|
Code | Expected | Actual |
[1,2,3].reverse |
[3, 2, 1] | [3, 2, 1] |
[1,[2,3,4],5].reverse |
[5, [2, 3, 4], 1] | [5, [2, 3, 4], 1] |
a = [1,2,3] a.reverse! a |
[3, 2, 1] | [3, 2, 1] |