J
J
JSxNeet2017-10-20 09:19:19
ruby
JSxNeet, 2017-10-20 09:19:19

How to reproduce inserting an element in the middle of an array without losing elements?

How is it possible to reproduce this action? If I understand correctly, then it is necessary to "remember" the element that will be lost and somehow "glue" them together. Thanks in advance for your reply.
Sample additional element:
9
Sample array:
[ 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ]
Desired output:
[ 1 , 2 , 3 , 4 , 9 , 5 , 6 , 7 , 8 ]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2017-10-20
@JSxNeet

I heard that there is an insert method - you specify the position and the elements you want to insert.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question