Hi,
Here's the 3rd hint.
You can iterate backwards over an array with the following code:
def reverse_each(arr)
(arr.size - 1).downto(0) { |i| print arr[i] }
end
reverse_each([3, 2, 1]) # 123
One question about the code above: why did I write (arr.size - 1)?
Look for hint #4 later today.
Glenn
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment