# How to create a reversed view that allows for growing arrays?

**URL:** <https://discourse.julialang.org/t/how-to-create-a-reversed-view-that-allows-for-growing-arrays/96148>\
**Category:** General Usage\
**Created:** [March 15, 2023, 7:23pm UTC](https://discourse.julialang.org/t/how-to-create-a-reversed-view-that-allows-for-growing-arrays/96148 "2023-03-15T19:23:52Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![simsurace](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simsurace/32/30216_2.png) [@simsurace](https://discourse.julialang.org/u/simsurace)\
**Post date:** [March 15, 2023, 8:28pm UTC](https://discourse.julialang.org/t/how-to-create-a-reversed-view-that-allows-for-growing-arrays/96148/2 "2023-03-15T20:28:11Z")

</div>

I think this is the use case for a `Reversed` wrapper that constructs a range when `getindex` is called:

```julia
struct Reversed{T<:AbstractArray}
    A::T
end

Base.getindex(a::Reversed, i::Int) = a.A[end-i+1]

v = [1, 2, 3]
a = Reversed(v)
a[1] # 3
push!(v, 4)
a[1] # 4

```

---

_[View the full topic](https://discourse.julialang.org/t/how-to-create-a-reversed-view-that-allows-for-growing-arrays/96148)._
