Ruby - Arrays
What is the output of the following Ruby code?
arr = [1, [2, 3], [4, [5]]] puts arr.flatten.length
arr = [1, [2, 3], [4, [5]]] puts arr.flatten.length
flatten to the array[1, [2, 3], [4, [5]]] becomes [1, 2, 3, 4, 5] after flattening.length returns 5.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions