In this HackerRank Ruby Array - Initialization problem solution One of the most commonly used data structures in Ruby is a Ruby Array, and below we see various methods of initializing a ruby array.
Your task is to initialize three different variables as explained below.
Initialize an empty array with the variable name array
Problem solution in Ruby Programming.
# Initialize 3 variables here as explained in the problem statement array = Array.new array1 = Array.new(1) array2 = Array.new(2,10)
Second solution
# Initialize 3 variables here as explained in the problem statement array = [] array1 = [nil] array2 = Array.new(2, 10)

0 Comments