Home / Programming MCQs / Ruby MCQs / Question

Y

Yami Thakur • 9.05K Points
Tutor III

Q. In Ruby, Array index -1 represent ______.

(A) First Element
(B) Last element
(C) Middle element
(D) Reverse the array
Explanation by: Yami Thakur
A negative index is assumed relative to the end of the array --- that is, an index of -1 indicates the last element of the array, -2 is the next to last element in the array, and so on.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.