# How to initialize array of arrays with specific type?

**URL:** <https://discourse.julialang.org/t/how-to-initialize-array-of-arrays-with-specific-type/94557>\
**Category:** General Usage\
**Tags:** type, arrays, interpolations, interpolationsjl\
**Created:** [February 13, 2023, 1:15pm UTC](https://discourse.julialang.org/t/how-to-initialize-array-of-arrays-with-specific-type/94557 "2023-02-13T13:15:58Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [February 13, 2023, 1:27pm UTC](https://discourse.julialang.org/t/how-to-initialize-array-of-arrays-with-specific-type/94557/3 "2023-02-13T13:27:53Z")

</div>

What you are using to fill the array `A` is the `DataType` of the interpolation. To use `A[1] = ...` you need an array of instances of the interpolation. For example:

```julia
julia> b = interpolate( B, BSpline(Cubic(Line(OnGrid()))));

julia> A = fill(copy(b), 10);

julia> A[1] = interpolate( B, BSpline(Cubic(Line(OnGrid()))));

```

Otherwise you may just want an empty array of interpolations, such as:

```julia
julia> A = typeof(b)[]
Interpolations.BSplineInterpolation{Float64, 2, OffsetMatrix{Float64, Matrix{Float64}}, BSpline{Cubic{Line{OnGrid}}}, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}[]

julia> push!(A, interpolate( B, BSpline(Cubic(Line(OnGrid())))))
1-element Vector{Interpolations.BSplineInterpolation{Float64, 2, OffsetMatrix{Float64, Matrix{Float64}}, BSpline{Cubic{Line{OnGrid}}}, Tuple{Base.OneTo{Int64}, Base.OneTo{Int64}}}}:
 [0.6382324838466641 0.15737452960821852 … 0.39607517204553827 0.15889649188608557; 0.13177398720760136 0.6391502891054832 … 0.9749632710156909 0.23570550771235294; … ; 0.26655297042787274 0.3298620168301782 … 0.09981476823205598 0.3372852663412892; 0.4963880643359818 0.10982508349889288 … 0.792355741208348 0.5513251663389037]

```

but then you need to `push!` to it.

(of if you really want an array of empty arrays of interpolations, `A = fill(typeof(b)[], 10,20)`, in which case you need `push!(A[1], interpolate(...))`. )

---

_[View the full topic](https://discourse.julialang.org/t/how-to-initialize-array-of-arrays-with-specific-type/94557)._
