# Redirecting from a variable to an array

**URL:** <https://forums.unrealengine.com/t/redirecting-from-a-variable-to-an-array/1765109>\
**Category:** Programming & Scripting\
**Tags:** redirector, unreal-engine, editor, question\
**Created:** [March 21, 2024, 2:08pm UTC](https://forums.unrealengine.com/t/redirecting-from-a-variable-to-an-array/1765109 "2024-03-21T14:08:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DarioGangi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dariogangi/32/1215012_2.png) [@DarioGangi](https://forums.unrealengine.com/u/DarioGangi)\
**Post date:** [March 21, 2024, 2:08pm UTC](https://forums.unrealengine.com/t/redirecting-from-a-variable-to-an-array/1765109/1 "2024-03-21T14:08:28Z")

</div>

Can I redirect a variable to an array?  
i.e.: I’ve this class:

```auto
UCLASS()
void UMyClass : public UObject
{
GENERATED_BODY()

UPROPERTY(EditAnywhere)
int32 Variable{};
};

```

I would like to modify Variable into a list of integers and rename it in Variables:

```auto
UCLASS()
void UMyClass : public UObject
{
GENERATED_BODY()

UPROPERTY(EditAnywhere)
TArray<int32> Variables{};
};

```

I tried to modify the DefaultEngine.ini file of my project…

```auto
[CoreRedirects]
+PropertyRedirects=(OldName="MyClass.Variable",NewName="MyClass.Variables[0]")

```

… and unfortunately it doesn’t work. How can I redirect it?

I thought I could override PreSave() method and transfer Variable into Variables, then resave all assets in Unreal Editor and then remove Variable from the code, but I’m wondering if a better solution exists.

---

<div class="post-metadata">

**Author:** ![DarioGangi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dariogangi/32/1215012_2.png) [@DarioGangi](https://forums.unrealengine.com/u/DarioGangi)\
**Post date:** [March 21, 2024, 2:26pm UTC](https://forums.unrealengine.com/t/redirecting-from-a-variable-to-an-array/1765109/2 "2024-03-21T14:26:03Z")

</div>

So far the solution I’ve found is override PreSave() method:

```auto
UCLASS()
void UMyClass : public UObject
{
GENERATED_BODY()

void PreSave(FObjectPreSaveContext SaveContext) override
{
      Super::PreSave(SaveContext);
      Variables.Empty();
      Variables.Emplace(Variable);
}

UPROPERTY(EditAnywhere)
TArray<int32> Variables{};

UPROPERTY(EditAnywhere)
int32 Variable{};
};

```

In this way I can resave my assets and remove _int32 Variable_ from code (and _PreSave()_ method).
