Set TArray Default Value UProperty

Hey guys,
a quick question here. When declaring a UProperty that is TArray, how do you recommend to set the default values for said Variable inside the Header file?

I understand that the std method is by std::fill_n(array, index, value), but was curious to see how Unreal prefers data to be saved, especially within the header.

Could you provide an example of the recommended fashion? I’m particularly interested in how things like Enum Classes are stored within the declaration of the default Array Values.

Thank you very much!

Hey,
As descibed on this question : TArray initialization - Programming & Scripting - Unreal Engine Forums

 TArray<int32> table = {4, 8, 15, 16, 23, 42};

internaly is us std::initializer_list for this behaviour

But i’m not aware of any way to fill an array of size X with N as default value in the header

Okay, this way I also knew.

I see. Any clues on how it would work?

The Coding Standard also explains the advantages and downsides to initializing in the header and right above that it explains Strongly Typed Enums.

1 Like

I’ve also looked into this already. It does not state anywhere for TArray Initialization.