# Changing the array base at runtime

**URL:** <https://discourse.julialang.org/t/changing-the-array-base-at-runtime/5039>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [July 24, 2017, 10:26am UTC](https://discourse.julialang.org/t/changing-the-array-base-at-runtime/5039 "2017-07-24T10:26:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![leiteiro](https://avatars.discourse-cdn.com/v4/letter/l/b5e925/32.png) [@leiteiro](https://discourse.julialang.org/u/leiteiro)\
**Post date:** [July 24, 2017, 10:26am UTC](https://discourse.julialang.org/t/changing-the-array-base-at-runtime/5039/1 "2017-07-24T10:26:39Z")

</div>

I intend to drive my annoying software tester into the madness.

For this, I would like to change the base of an array at runtime, between  
the normal (1-based) mode and a different one (defined via OffsetArrays).

How do I do this most efficiently?

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [July 24, 2017, 10:37am UTC](https://discourse.julialang.org/t/changing-the-array-base-at-runtime/5039/2 "2017-07-24T10:37:33Z")

</div>

Since `OffsetArray` is `immutable`, you cannot change the offsets of an existing one. Best you can do is create another one with the same contents and different offset. Or if you insist on doing the above, you need to roll your own `mutable struct` (doing this is pretty common for unit tests).
