# Whats the difference between a Array & Generator in Verse?

**URL:** <https://forums.unrealengine.com/t/whats-the-difference-between-a-array-generator-in-verse/2110002>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, question, fortnite\
**Created:** [November 7, 2024, 5:53pm UTC](https://forums.unrealengine.com/t/whats-the-difference-between-a-array-generator-in-verse/2110002 "2024-11-07T17:53:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![VETZBR](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/vetzbr/32/892910_2.png) [@VETZBR](https://forums.unrealengine.com/u/VETZBR)\
**Post date:** [November 7, 2024, 5:53pm UTC](https://forums.unrealengine.com/t/whats-the-difference-between-a-array-generator-in-verse/2110002/1 "2024-11-07T17:53:01Z")

</div>

Recently, the function GetCreativeObjectsWithTag was deprecetad, the new FindCreativeObjectsWithTag returns a Generator instead a array, and we cant acess index in this generator

what’s the main difference? and what’s the best pratice to work with tags in classes that are not creative devices?

---

<div class="post-metadata">

**Author:** ![im\_a\_lama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/im_a_lama/32/995063_2.png) [@im\_a\_lama](https://forums.unrealengine.com/u/im_a_lama)\
**Post date:** [November 8, 2024, 8:46am UTC](https://forums.unrealengine.com/t/whats-the-difference-between-a-array-generator-in-verse/2110002/2 "2024-11-08T08:46:01Z")

</div>

Hi VETZ, generators can only be used inside `for` loops, which means you can’t ask for an element at a certain index or ask for the generator length  
Also all the array functions are not available in generators

This change is only relevant because they found multiple performance issues regarding arrays, in the future there’s no point in using generators instead of arrays

```auto
A := []int

for(Element : A) { } # Works
Size := A.Length # Works (but is not performant rn)
if(FirstElement := A[0]): # Works if there's atleast one element in the array

B := generator(int){}
for(Element : B) { } # Works
Size := B.Length # Doesn't work
if(FirstElement := B[0]): # Doesn't work

```

Array functions you can’t use in generators (as of 32.00)

```auto
    (Input:[]t where t:type).Slice<public>(StartIndex:int, StopIndex:int)<computes><decides>:[]t = external {}
    (Input:[]t where t:type).Slice<public>(StartIndex:int)<computes><decides>:[]t = external {}
    (Input:[]t where t:type).Insert<public>(InsertionIndex:int, ElementsToInsert:[]t)<computes><decides>:[]t = external {}
    (Input:[]t where t:type).RemoveElement<public>(IndexToRemove:int)<computes><decides>:[]t = external {}
    (Input:[]t where t:subtype(comparable)).RemoveFirstElement<public>(ElementToRemove:t)<computes><decides>:[]t = external {}
    (Input:[]t where t:subtype(comparable)).RemoveAllElements<public>(ElementToRemove:t)<computes>:[]t = external {}
    (Input:[]t where t:type).ReplaceElement<public>(IndexToReplace:int, ElementToReplaceWith:t)<computes><decides>:[]t = external {}
    (Input:[]t where t:subtype(comparable)).ReplaceFirstElement<public>(ElementToReplace:t, ElementToReplaceWith:t)<computes><decides>:[]t = external {}
    (Input:[]t where t:subtype(comparable)).ReplaceAllElements<public>(ElementToReplace:t, ElementToReplaceWith:t)<computes>:[]t = external {}
    (Input:[]t where t:subtype(comparable)).ReplaceAll<public>(ElementsToReplace:[]t, Replacement:[]t)<transacts>:[]t = external {}
    (Input:[]t where t:type).Remove<public>(StartIndex:int, StopIndex:int)<computes><decides>:[]t = external {}
    (Input:[]t where t:subtype(comparable)).Find<public>(ElementToFind:t)<computes><decides>:int = external {}

    Concatenate<public>(Arrays:[][]t where t:type)<computes>:[]t = external {}
    Shuffle<public>(Input:[]t where t:type)<transacts>:[]t = external {}

```

---

<div class="post-metadata">

**Author:** ![ok\_studios](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ok\_studios](https://forums.unrealengine.com/u/ok_studios)\
**Post date:** [November 10, 2024, 3:57am UTC](https://forums.unrealengine.com/t/whats-the-difference-between-a-array-generator-in-verse/2110002/3 "2024-11-10T03:57:16Z")

</div>

This video might help:

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/1/0/a10bded11bfb0d1d71e987f2d7c2e2a2e2eb2591.jpeg "Find Creative Objects With Tag in Verse Code: Now Returns A Generator Instead of An Array") ](https://www.youtube.com/watch?v=2DElMcs0KSY)

---

<div class="post-metadata">

**Author:** ![Mineblo](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/mineblo/32/1203575_2.png) [@Mineblo](https://forums.unrealengine.com/u/Mineblo)\
**Post date:** [November 10, 2024, 4:19am UTC](https://forums.unrealengine.com/t/whats-the-difference-between-a-array-generator-in-verse/2110002/4 "2024-11-10T04:19:45Z")

</div>

> [@im\_a\_lama](#):
>
> `(but is not performant rn)`

What do you mean exactly with this? is getting the length not good performance wise on any array?

---

<div class="post-metadata">

**Author:** ![im\_a\_lama](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/im_a_lama/32/995063_2.png) [@im\_a\_lama](https://forums.unrealengine.com/u/im_a_lama)\
**Post date:** [November 10, 2024, 9:32am UTC](https://forums.unrealengine.com/t/whats-the-difference-between-a-array-generator-in-verse/2110002/5 "2024-11-10T09:32:59Z")

</div>

It was hidden in the patchnote (inside the new verse procedural template)

> **[Procedural Building Template | Unreal Editor for Fortnite Documentation |...](https://dev.epicgames.com/documentation/en-us/uefn/procedural-building-template-in-unreal-editor-for-fortnite#verseperformance)**
>
> Use the Verse - Procedural Building as a starting point to fine-tune your level design skills.
