ruby array replace element

# 1. Create an array with initial elements
original_array = [1, 2, 3, 4, 5]

# 2. Specify the index of the element to be replaced
index_to_replace = 2

# 3. Define the new value to replace the existing element
new_value = 10

# 4. Replace the element at the specified index with the new value
original_array[index_to_replace] = new_value

# 5. Print the modified array
puts original_array