Can't figure out how my array is being overwritten/reset

How is SubbedFunctions length = 1 after I call Subscribe twice?

round_ended_subscribable := class():
    var SubbedFunctions<private>:[]round_ended_function = array{}
    
    Subscribe<public>(Function:round_ended_function):void =
        Print("Round Ended Subscribe")
        set SubbedFunctions += array{Function}
        Print("S: RE Subbed Functions Length= {SubbedFunctions.Length}")
    
    Dispatch<internal>():void =
        Print("D: RE Subbed Functions Length= {SubbedFunctions.Length}")
        for (Function:SubbedFunctions):
            Print("Dispatched from Round Ended")
            Function()
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }


hello_world_device := class(creative_device):
    
    var MyArray<private>: []int = array{}


    OnBegin<override>()<suspends>:void=

        AddInt(1)
        AddInt(2)
        


    AddInt(i: int): void=
        set MyArray += array{i}    
        Print("My array length is: {MyArray.Length}", ?Duration:=10.0)

It is curious, isn’t it? Is it truly being called 2x? Code snippet doesn’t show how call is being made.
The code above, which follows yours, gives an array length of 2 when called 2x.

I am afraid that I have to report that I did not have the correct device linked in the editor :confused:. Wish there was some better way for the code to fail when this happens, instead I went mental for 4 days. Thanks for the help!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.