Ruby - Arrays
Which of the following is the correct syntax to create an array with 3 elements, all initialized to zero?
Array.new(size, default_value) creates an array with given size and fills it with the default value.Array.new(3, 0) correctly creates [0, 0, 0]. Array.new(0, 3) creates an empty array since size is first argument. Options C and D are invalid syntax.15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions