# Can't Add Objects to a TArray

**URL:** <https://forums.unrealengine.com/t/cant-add-objects-to-a-tarray/489479>\
**Category:** C++\
**Tags:** tarray, unreal-engine, CPP, question\
**Created:** [October 3, 2021, 6:14pm UTC](https://forums.unrealengine.com/t/cant-add-objects-to-a-tarray/489479 "2021-10-03T18:14:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jarred003](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jarred003/32/88710_2.png) [@Jarred003](https://forums.unrealengine.com/u/Jarred003)\
**Post date:** [October 3, 2021, 6:14pm UTC](https://forums.unrealengine.com/t/cant-add-objects-to-a-tarray/489479/1 "2021-10-03T18:14:17Z")

</div>

Hello,  
i’m a Unreal Engine beginner, i’m not able to add objects to my TArray.

```
UPROPERTY(BlueprintReadWrite, Category = "Code")
		TArray<UTrash*> Trashes;

```

When a call TArray::Add nothing happends and TArray::Num is still 0.

```
Trashes.Add(NewObject<UTrash>());
UE_LOG(LogTemp, Warning, TEXT("Elements: %f"),Trashes.Num()); //It always writes 0!

```

UTrash is a my custom class, should the problem be in UTrash?  
Thanks for the help.

---

<div class="post-metadata">

**Author:** ![BlackCryptix](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BlackCryptix](https://forums.unrealengine.com/u/BlackCryptix)\
**Post date:** [April 16, 2022, 11:32am UTC](https://forums.unrealengine.com/t/cant-add-objects-to-a-tarray/489479/3 "2022-04-16T11:32:55Z")

</div>

Trashes.Num() returns an int value but %f logs a float. If you want to log an int value use %d.

For other values see:

> **[Logging | Unreal Engine Community Wiki](https://unrealcommunity.wiki/logging-lgpidy6i)**
>
> Logging means keeping an ordered record of events, function calls, variable values at a certain time during runtime, etc. This is usually saved in the form of text in a log file.
