# Array index out of bounds condition checking macro

**URL:** <https://forums.unrealengine.com/t/array-index-out-of-bounds-condition-checking-macro/373922>\
**Category:** Platform & Builds\
**Tags:** randomize-array, tarray:-arrays-in-un, unreal-engine, question\
**Created:** [October 20, 2016, 2:53pm UTC](https://forums.unrealengine.com/t/array-index-out-of-bounds-condition-checking-macro/373922 "2016-10-20T14:53:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![SwordsKeyboard](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SwordsKeyboard](https://forums.unrealengine.com/u/SwordsKeyboard)\
**Post date:** [October 20, 2016, 2:53pm UTC](https://forums.unrealengine.com/t/array-index-out-of-bounds-condition-checking-macro/373922/1 "2016-10-20T14:53:48Z")

</div>

I’m getting the below crash after I spawn an actor

Assertion failed: (Index \>= 0) & (Index \< ArrayNum)  
Array index out of bounds: 1 from an array of size 1

Would this macro work as a check against that? I am using a lot of isContains/ForeachLoops with arrays

[](https://i.imgur.com/13g5CD4.png)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_41845f4a](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_41845f4a](https://forums.unrealengine.com/u/anonymous_user_41845f4a)\
**Post date:** [October 20, 2016, 9:15pm UTC](https://forums.unrealengine.com/t/array-index-out-of-bounds-condition-checking-macro/373922/2 "2016-10-20T21:15:52Z")

</div>

Hello .,

Assuming Last Index (never used that node) returns the index while accounting for 0 base, this should work from what I understand these values to be. What is New Param 1-4? What is Get Check? The only thing I notice that is out of place is the second branch. That branch is checking the same boolean from the previous branch. It’s always going to be true if the previous one was true, and is only called when the first branch is true, so it seems redundant.

---

<div class="post-metadata">

**Author:** ![SwordsKeyboard](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SwordsKeyboard](https://forums.unrealengine.com/u/SwordsKeyboard)\
**Post date:** [October 20, 2016, 9:33pm UTC](https://forums.unrealengine.com/t/array-index-out-of-bounds-condition-checking-macro/373922/3 "2016-10-20T21:33:59Z")

</div>

The get check is to see if the index falls within the length of the array so I don’t get array out of bounds crash

param 1 is the exit after passing all the checks including get check if enabled,  
param 2 is the wildcard array,  
param 3 is the get index I want to check,  
param 4 is complete is fail for both length/get check

I need to switch the places of the two branches. So the length is valid and I can go ahead and check if the get I am running on the outside will be valid

---

<div class="post-metadata">

**Author:** ![SwordsKeyboard](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SwordsKeyboard](https://forums.unrealengine.com/u/SwordsKeyboard)\
**Post date:** [October 20, 2016, 9:44pm UTC](https://forums.unrealengine.com/t/array-index-out-of-bounds-condition-checking-macro/373922/4 "2016-10-20T21:44:55Z")

</div>

My finished product

[http://i.imgur.com/DQ7I9QL.png](http://i.imgur.com/DQ7I9QL.png)

---

<div class="post-metadata">

**Author:** ![iskander\_b](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@iskander\_b](https://forums.unrealengine.com/u/iskander_b)\
**Post date:** [October 27, 2021, 10:38am UTC](https://forums.unrealengine.com/t/array-index-out-of-bounds-condition-checking-macro/373922/5 "2021-10-27T10:38:03Z")

</div>

there’s a “is valid index” macro which I assume does the same thing here
