Ruby - Arrays
What is the output of the following Ruby code?
arr = [10, 20, 30, 40, 50] puts arr[2] puts arr.first puts arr[-2]
arr = [10, 20, 30, 40, 50] puts arr[2] puts arr.first puts arr[-2]
arr[2]arr.first and arr[-2]arr.first is 10 (first element), arr[-2] is second last element, 40.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions