# What's the trick to defining an array param in a UFUNCTION?

**URL:** <https://forums.unrealengine.com/t/whats-the-trick-to-defining-an-array-param-in-a-ufunction/286333>\
**Category:** Blueprint\
**Tags:** unreal-engine, CPP, Blueprint, question\
**Created:** [June 19, 2014, 8:03pm UTC](https://forums.unrealengine.com/t/whats-the-trick-to-defining-an-array-param-in-a-ufunction/286333 "2014-06-19T20:03:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![MSE\_Taliesin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MSE\_Taliesin](https://forums.unrealengine.com/u/MSE_Taliesin)\
**Post date:** [June 19, 2014, 8:03pm UTC](https://forums.unrealengine.com/t/whats-the-trick-to-defining-an-array-param-in-a-ufunction/286333/1 "2014-06-19T20:03:23Z")

</div>

I have 2 UENUM enumerated types: EGameResource and EGameResourceTypes.

```
UFUNCTION( BlueprintCallable, Category=MyGame)
void DefineResourceTypes( TArray<EGameResource> & Resources, EGameResourceTypes ResourceType );

```

The compiler sadly informs me that

OCResourceConversionDefinitions.h(26): error C2664: ‘void AOCResourceConversionDefinitions::DefineResourceTypes(TArray &,EGameResourceTypes)’ : cannot convert argument 1 from ‘TArray,FDefaultAllocator\>’ to ‘TArray &’

What on earth is going on? How am I supposed to define an array of enums for a function exposed as a UFUNCTION?

---

<div class="post-metadata">

**Author:** ![MSE\_Taliesin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MSE\_Taliesin](https://forums.unrealengine.com/u/MSE_Taliesin)\
**Post date:** [June 19, 2014, 8:15pm UTC](https://forums.unrealengine.com/t/whats-the-trick-to-defining-an-array-param-in-a-ufunction/286333/2 "2014-06-19T20:15:18Z")

</div>

OK – I seem to be able to work around it by changing the array to a TEnumAsByte:

```
void DefineResourceTypes( TArray<TEnumAsByte<EGameResource> > & Resources, EGameResourceTypes ResourceType );

```

Unfortunately, I am seeing that the array is, for some reason, getting treated as an OUTPUT parameter instead of the INPUT parameter it’s actually intended to be. What gives?

![8816-array_as_output.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/4/4/e44f6b563d750862bd7a517c80fdbc8e75859c7e.png)

---

<div class="post-metadata">

**Author:** ![Dartanlla](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/dartanlla/32/724052_2.png) [@Dartanlla](https://forums.unrealengine.com/u/Dartanlla)\
**Post date:** [June 19, 2014, 8:31pm UTC](https://forums.unrealengine.com/t/whats-the-trick-to-defining-an-array-param-in-a-ufunction/286333/3 "2014-06-19T20:31:06Z")

</div>

If you add const in front of your reference type parameter it will make it an input on the blueprint:

void DefineResourceTypes( const TArray \> & Resources, EGameResourceTypes ResourceType );

By default, pass by reference parameters are treated as outputs on blueprint nodes.

---

<div class="post-metadata">

**Author:** ![MSE\_Taliesin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MSE\_Taliesin](https://forums.unrealengine.com/u/MSE_Taliesin)\
**Post date:** [June 19, 2014, 10:29pm UTC](https://forums.unrealengine.com/t/whats-the-trick-to-defining-an-array-param-in-a-ufunction/286333/4 "2014-06-19T22:29:47Z")

</div>

Thanks – works like charm!

---

<div class="post-metadata">

**Author:** ![plojnitza](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@plojnitza](https://forums.unrealengine.com/u/plojnitza)\
**Post date:** [November 8, 2016, 11:05am UTC](https://forums.unrealengine.com/t/whats-the-trick-to-defining-an-array-param-in-a-ufunction/286333/5 "2016-11-08T11:05:01Z")

</div>

If you want the array to remain editable, try the UPARAM(ref)

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...
