Complete the code to create an empty array in Ruby.
my_array = [1]In Ruby, arrays are created using square brackets [].
Complete the code to add the number 5 to the end of the array.
numbers = [1, 2, 3] numbers.[1](5) puts numbers.inspect
The push method adds an element to the end of an array.
Fix the error in the code to access the first element of the array.
fruits = ['apple', 'banana', 'cherry'] first = fruits[1] puts first
Arrays in Ruby use square brackets with zero-based indexes to access elements.
Fill both blanks to create an array of squares for numbers 1 to 5.
squares = (1..5).[1] { |n| n [2] n } puts squares.inspect
The map method transforms each number by multiplying it by itself.
Fill all three blanks to select even numbers and double them.
result = (1..10).[1] { |x| x [2] 2 == 0 }.[3] { |x| x * 2 } puts result.inspect
First, select filters even numbers using the modulo operator %, then map doubles each selected number.
