πŸ“Š Ruby
Q. In Ruby, Array index -1 represent ______.
  • (A) First Element
  • (B) Last element
  • (C) Middle element
  • (D) Reverse the array
πŸ’¬ Discuss
βœ… Correct Answer: (B) Last element

Explanation: 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.

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.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
249
Total Visits
πŸ“½οΈ
3 y ago
Published
πŸŽ–οΈ
Yami Thakur
Publisher
πŸ“ˆ
87%
Success Rate