# Verse Array

**URL:** <https://forums.unrealengine.com/t/verse-array/814962>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, fortnite\
**Created:** [March 24, 2023, 4:12am UTC](https://forums.unrealengine.com/t/verse-array/814962 "2023-03-24T04:12:25Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![4lvaro](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@4lvaro](https://forums.unrealengine.com/u/4lvaro)\
**Post date:** [March 24, 2023, 4:12am UTC](https://forums.unrealengine.com/t/verse-array/814962/1 "2023-03-24T04:12:25Z")

</div>

I have an array and I want to push a element at the end of this but I can’t find any form without have to put in the method. How is this possible?

---

<div class="post-metadata">

**Author:** ![sonictke](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sonictke/32/924209_2.png) [@sonictke](https://forums.unrealengine.com/u/sonictke)\
**Post date:** [March 24, 2023, 4:44pm UTC](https://forums.unrealengine.com/t/verse-array/814962/2 "2023-03-24T16:44:41Z")

</div>

Hi:

Arrays in Verse are immutable (they cannot be changed), but what you can do is assign a new array to the variable you’ve previously assigned the old one to.

Please refer to [Array](https://dev.epicgames.com/documentation/en-us/uefn/array-in-verse#changinganarrayanditselements) for more information to see how to create a new array with your extra element and assign it to your identifier.

```auto
var Array2:[]int = array{20, 21, 22}
set Array2 = Array2 + array{30, 31}

```

---

<div class="post-metadata">

**Author:** ![TwitchZeyrox679](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@TwitchZeyrox679](https://forums.unrealengine.com/u/TwitchZeyrox679)\
**Post date:** [March 27, 2023, 11:47am UTC](https://forums.unrealengine.com/t/verse-array/814962/3 "2023-03-27T11:47:40Z")

</div>

Sorry sonictke can you tell me why i have this error?

 ![Cattura](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/a/7/ba71f273f5fa7811f2af969eb2430ffc579bad71.png)

---

<div class="post-metadata">

**Author:** ![kiranmaya](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@kiranmaya](https://forums.unrealengine.com/u/kiranmaya)\
**Post date:** [March 27, 2023, 11:53am UTC](https://forums.unrealengine.com/t/verse-array/814962/4 "2023-03-27T11:53:03Z")

</div>

Use := , if needed a fail proof condition, I hav’t started writing verse , just browsing trough docs , try it , let me know.

---

<div class="post-metadata">

**Author:** ![gontux](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/gontux/32/642085_2.png) [@gontux](https://forums.unrealengine.com/u/gontux)\
**Post date:** [March 27, 2023, 5:42pm UTC](https://forums.unrealengine.com/t/verse-array/814962/5 "2023-03-27T17:42:08Z")

</div>

Seems like appending values to an array is something that can’t fail. Try this:

```auto
var Array2:[]int = array{20, 21, 22}
set Array2 += array{30, 31}

```

---

<div class="post-metadata">

**Author:** ![sonictke](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/sonictke/32/924209_2.png) [@sonictke](https://forums.unrealengine.com/u/sonictke)\
**Post date:** [March 27, 2023, 10:20pm UTC](https://forums.unrealengine.com/t/verse-array/814962/6 "2023-03-27T22:20:44Z")

</div>

As @gontux mentioned above, that is correct, you don’t need to wrap it in a failure context for this. I’ve updated the sample in my original post.

---

<div class="post-metadata">

**Author:** ![DragonRage508](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dragonrage508/32/677485_2.png) [@DragonRage508](https://forums.unrealengine.com/u/DragonRage508)\
**Post date:** [May 3, 2023, 2:44am UTC](https://forums.unrealengine.com/t/verse-array/814962/7 "2023-05-03T02:44:13Z")

</div>

This is odd because by your statement I should not be able to do the following:

set Foo[Index] -= ThisAmount

Where ‘Foo’ is an array of type float and ‘ThisAmount’ is of type float. BUT, when I type this in, no errors appear, but the line seems to not function whatsoever. Does this mean mutable arrays are coming in a future update to Verse? Or maybe a type Vector?

---

<div class="post-metadata">

**Author:** ![meatandmeat](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@meatandmeat](https://forums.unrealengine.com/u/meatandmeat)\
**Post date:** [May 3, 2023, 7:33pm UTC](https://forums.unrealengine.com/t/verse-array/814962/8 "2023-05-03T19:33:27Z")

</div>

if(set Foo[Index] -= ThisAmount]) should work, but if you’re doing it inside of a for loop, it seems like Verse makes copies to iterate over, so in`for(I:=0..Array.Length-1; X:=Array[I]){set Array[I] += 10; Print("{X}")}` It will just print the original array.  
But after the for loop, the values should have changed.

---

<div class="post-metadata">

**Author:** ![ChrixBed](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/chrixbed/32/702407_2.png) [@ChrixBed](https://forums.unrealengine.com/u/ChrixBed)\
**Post date:** [October 21, 2023, 2:29pm UTC](https://forums.unrealengine.com/t/verse-array/814962/10 "2023-10-21T14:29:44Z")

</div>

How about a multidimensional array? I can’t figure out the right syntax for it, any suggestions?

```auto
var MyArray : [][]int = array {}
for(Row := 0..9):
	for (Column := 0..9)
		if(set MyArray[Row][Column] += array{GetRandomInt(0, 100)}){}

```
