How to push scalar into an empty vector

Hi all!
I’m trying to create an empty vector that will be pushed with values inside a for loop. I tried the following:


δ_arr = Vector{Any}[]
ϵ₀_arr = Vector{Any}[]
M_arr = range(0.01e6, 0.9e6, 10)

	for i in 1:length(M_arr)
		ep, si, t_b, lag, amp = strain_ampli_f(𝑓, M_arr[i], B_g)
		push!(ϵ₀_arr, amp)
		push!(δ_arr, lag)
	end	

But for some reason I’m getting:

MethodError: Cannot `convert` an object of type Float64 to an object of type Vector{Any}

On the push command. Not sure what I’m missing. Appreciate any help!!
Thank you!

You want Any[] (or just []). Vector{Any}[] is a Vector that stores Vector{Any}s.

1 Like

Perfect!! That was lightning fast and enlightening :slight_smile: