Should insert! not be able to insert a collection?

x = [1,2,7,8]
y = [3,4,5,6]
insert!(x,2+1,y)

Is then unable to complete the insertion and create [1,2,3,4,5,6,7,8]. 
There is a costlier way to do this at the moment however.

splice! almost replicates the required functionality but it replaces the 
item at 2 instead of inserting items after position2.

x = [1,2,7,8]
y = [3,4,5,6]
splice!(x,2,unshift!(y,x[2]))

This is about 20% slower but does work.
 
I was surprised that insert! inserts the item before the item at that index 
instead of after. Could this perhaps be mentioned in the doc for insert!?
Perhaps my Google-Fu is weak, but I could not find any reference to say 
which behaviour it should have.

Just wanted to point out that currently insert! only works for a single 
item instead of a single item and collections and to inquire if there is 
not perhaps a better workaround than the above.

Thanks!

Reply via email to