Bool MyFunc(int32* myInt); vs void MyFunc(int32* myInt, bool &MyBool);

Depends, what is that bool used for?

If it’s a return value, then the first one is a bit cleaner, as you don’t have to predefine a bool variable, especially in case you want to use it directly in an if condition.

However, if you actually want to modify an existing bool, then you can only choose the second one.

Generally, the second format is usually used when you want to return multiple values.

bool MyFunc(int32* myInt);
or

void MyFunc(int32* myInt, bool &MyBool);

is it simply the need to create a reference to MyBool?
Why use which one?

When I use the first method, the output node in the blueprint always shows “Return Value”, but with the second method it will either be the name of the parameter or whatever you specify with UPARAM(DisplayName = “XYZ”) - I haven’t seen a way to do that with the first method.

Also with the second method, the parameter won’t show up in blueprints as an input node, only an output node.

Thanks for the clarification!

I was aware of what both functions do, but I wasn’t sure why and what one I should use :), thanks for the input!

I don’t think there would be a way to explicitly set an un-referenced var at the beginning of the function, perhaps with a macro that calls a return with VA_ARG as inputs, but that’s still the same function just secretly redefined…would be good for coding your own return system I guess :slight_smile: