ruby array remove by index
# Initialize an array
arr = [1, 2, 3, 4, 5]
# Define the index to be removed
index_to_remove = 2
# Remove the element at the specified index
arr.delete_at(index_to_remove)
# Display the updated array
puts arr.inspect
# Initialize an array
arr = [1, 2, 3, 4, 5]
# Define the index to be removed
index_to_remove = 2
# Remove the element at the specified index
arr.delete_at(index_to_remove)
# Display the updated array
puts arr.inspect