Ruby - Class Methods and Variables
What will this code print?
class Array
def second
self[1]
end
end
arr = [10, 20, 30]
puts arr.secondclass Array
def second
self[1]
end
end
arr = [10, 20, 30]
puts arr.secondsecond method returns the element at index 1.arr.second returns 20.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions