# Set TArray Default Value UProperty

**URL:** <https://forums.unrealengine.com/t/set-tarray-default-value-uproperty/438969>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [December 6, 2018, 8:49am UTC](https://forums.unrealengine.com/t/set-tarray-default-value-uproperty/438969 "2018-12-06T08:49:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![atanknomore](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@atanknomore](https://forums.unrealengine.com/u/atanknomore)\
**Post date:** [December 6, 2018, 8:49am UTC](https://forums.unrealengine.com/t/set-tarray-default-value-uproperty/438969/1 "2018-12-06T08:49:45Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![Firefly74](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Firefly74](https://forums.unrealengine.com/u/Firefly74)\
**Post date:** [December 6, 2018, 3:32pm UTC](https://forums.unrealengine.com/t/set-tarray-default-value-uproperty/438969/2 "2018-12-06T15:32:56Z")

</div>

Hey,  
As descibed on this question : [TArray initialization - Programming & Scripting - Unreal Engine Forums](https://answers.unrealengine.com/questions/183185/tarray-initialization.html)

```
 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

---

<div class="post-metadata">

**Author:** ![atanknomore](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@atanknomore](https://forums.unrealengine.com/u/atanknomore)\
**Post date:** [December 6, 2018, 9:58pm UTC](https://forums.unrealengine.com/t/set-tarray-default-value-uproperty/438969/3 "2018-12-06T21:58:50Z")

</div>

Okay, this way I also knew.

I see. Any clues on how it would work?

---

<div class="post-metadata">

**Author:** ![Spidermined](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Spidermined](https://forums.unrealengine.com/u/Spidermined)\
**Post date:** [December 7, 2018, 3:12am UTC](https://forums.unrealengine.com/t/set-tarray-default-value-uproperty/438969/4 "2018-12-07T03:12:10Z")

</div>

The Coding Standard also explains the [advantages and downsides to initializing in the header](https://docs.unrealengine.com/en-us/Programming/Development/CodingStandard#defaultmemberinitializers) and right above that it explains Strongly Typed Enums.

---

<div class="post-metadata">

**Author:** ![atanknomore](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@atanknomore](https://forums.unrealengine.com/u/atanknomore)\
**Post date:** [December 7, 2018, 7:58am UTC](https://forums.unrealengine.com/t/set-tarray-default-value-uproperty/438969/5 "2018-12-07T07:58:55Z")

</div>

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