# General type of 2d arrays

**URL:** <https://discourse.julialang.org/t/general-type-of-2d-arrays/129394>\
**Category:** General Usage\
**Tags:** question, mesh\
**Created:** [May 28, 2025, 2:47am UTC](https://discourse.julialang.org/t/general-type-of-2d-arrays/129394 "2025-05-28T02:47:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cyan](https://avatars.discourse-cdn.com/v4/letter/c/278dde/32.png) [@Cyan](https://discourse.julialang.org/u/Cyan)\
**Post date:** [May 28, 2025, 2:47am UTC](https://discourse.julialang.org/t/general-type-of-2d-arrays/129394/1 "2025-05-28T02:47:08Z")

</div>

Hi, all. I am writing a function of 2d array, in which xg and yg are designed to be any format of `n x n` array. But I always encounter the errors of TypeError of xg and yg. Is there any widely general type of 2d array to avoid this error?

```julia
function Derivative(xg::Union{LazyGrids.GridSL, Matrix{Float64}},
         yg::Union{LazyGrids.GridSL, Matrix{Float64}})

```

---

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [May 28, 2025, 4:46am UTC](https://discourse.julialang.org/t/general-type-of-2d-arrays/129394/2 "2025-05-28T04:46:05Z")

</div>

```julia
AbstractMatrix

```

You can also generalize over the element type, by e.g. `foo(AbstractMatrix{T}) where {T:<Real}`, or even omitting the type parameter entiredly.
