The best way to create a AbstractArray with known first demension size

What is the best way to preallocate a Array with knowning the first demension size(that is 5), while keeping unchanged for other demension:

test_func(x::Array{T,N}) = Array{T,N}(undef,5,size(x)[2:end]...)

a_vec = [1,2,3]
a_mat = [[1,2,3] [2,3,4]]

test_func(a_vec) 
# [0,0,0,0,0]
test_func(a_mat) 
[
 0 0
 0 0 
 0 0 
 0 0 
 0 0 
]

Is there other better and brife ways to def test_func?

similar(a,5,Base.tail(size(a))...)

3 Likes