# How to reference element of array when compiler says that I'm trying to call a function with 'decides' effect

**URL:** <https://forums.unrealengine.com/t/how-to-reference-element-of-array-when-compiler-says-that-im-trying-to-call-a-function-with-decides-effect/1925426>\
**Category:** Verse\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, question, fortnite\
**Created:** [July 3, 2024, 3:30pm UTC](https://forums.unrealengine.com/t/how-to-reference-element-of-array-when-compiler-says-that-im-trying-to-call-a-function-with-decides-effect/1925426 "2024-07-03T15:30:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ForestTrener](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ForestTrener](https://forums.unrealengine.com/u/ForestTrener)\
**Post date:** [July 3, 2024, 3:30pm UTC](https://forums.unrealengine.com/t/how-to-reference-element-of-array-when-compiler-says-that-im-trying-to-call-a-function-with-decides-effect/1925426/1 "2024-07-03T15:30:50Z")

</div>

```auto
line_class := class<concrete>:

    @editable
    Title : string = "Title"
    @editable
    Description : string = "Message"
    @editable
    Decisions : []decision_class = array{}
    @editable
    Camera : gameplay_camera_fixed_point_device = gameplay_camera_fixed_point_device{}
    @editable
    Trigger : trigger_device = trigger_device{}
    @editable
    PopUpDialog : popup_dialog_device = popup_dialog_device{}

# A Verse-authored creative device that can be placed in a level
hello_world_device := class(creative_device):

    var Players : [] player = array {}

    @editable
    Button : button_device = button_device{}

    @editable
    MyLines:[]line_class = array{}

    var CurrentLine : int = 0

    # Runs when the device is started in a running game
    OnBegin<override>()<suspends>:void=

        Button.InteractedWithEvent.Subscribe(StartDialogue)

    StrToMsg<localizes>(S : string) : message = "{S}"

    StartDialogue(Agent : agent) : void =

        set CurrentLine = 0
        Initialization(CurrentLine, Agent)

    Initialization(LineNumber : int, Agent : agent) : void =

        LineNow : line_class = MyLines[LineNumber]

        Title : message = StrToMsg(LineNow.Title)
        Description : message = StrToMsg(LineNow.Description)
        PopUp : popup_dialog_device = LineNow.PopUpDialog
        Decisions : []decision_class = LineNow.Decisions

        PopUp.SetTitleText(Title)
        PopUp.SetDescriptionText(Description)
        for (Index := 0..Decisions.Length-1):
            DecisionNow : decision_class = Decisions[Index]
            PopUp.SetButtonText(StrToMsg(DecisionNow.Text), Index)
        
        PopUp.Show(Agent)
        PopUp.RespondingButtonEvent.Subscribe(DecisionMade)

```

In this code I have array “MyLines” of line\_class

When I’m trying to refernce one of the elements in “Initialization” function using MyLine[LineNumber] compiler says that I’m trying to call a function with “decides” effect. How to fix it?

---

<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:** [July 3, 2024, 3:54pm UTC](https://forums.unrealengine.com/t/how-to-reference-element-of-array-when-compiler-says-that-im-trying-to-call-a-function-with-decides-effect/1925426/2 "2024-07-03T15:54:50Z")

</div>

Hi.  
Any time you call an array, it is a failable expression. This is because when you call it, there might be nothing there and it will return as false or fail. All you have to do is call the array from within an IF or FOR expression. In other words, call it conditionally. MyLines needs to be called like this:  
if (MyLine[LineNumber]):

And then you can assign any value it returns IF it succeeds.

Perhaps this tutorial will help too:

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/1/d/91dbd304436c88176567bdbd7c8b11266ad9d9a3.jpeg "Accessing Elements in an Array in Verse (Unreal Editor for Fortnite)") ](https://www.youtube.com/watch?v=wiEZh9BZr2Q)
