Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

[Bug][Missing Documentation] BP Array Get and Find have inconsistent failed return values.


I think the docs should mention that array FIND function will return a value of -1 if it fails and that GET functions will return a null value if they fail.

I think INT array FIND and GET functions should have a Success BOOL output on the node since a NULL return is not distinguishable from a valid return if the array contains values of "-1"

Thanks to ScottSpadea for helping me properly define my issue!


  • ook

<<<<<<<<<<< ORIGINAL POST

Heya, I was wondering what array nodes like "Find" and "Get" would return when these functions failed and was sad to discover that this wasn't in the documentation. So I set up a test case to find out the answers and was further sad to discover they don't both return -1 which is confusing.


  1. They should both return -1 when they fail.

  2. They should throw a warning to the log so you can identify bad code.

  3. The return values should be documented: https://docs.unrealengine.com/latest/INT/Engine/Blueprints/UserGuide/Arrays/ArrayNodes/index.html

For benefit of those who come across this:

  1. A failed Array Get Returns: 0

  2. A failed Array Find Returns: -1


  • ook

Product Version: UE 4.10
more ▼

asked Feb 18 '16 at 06:23 PM in Blueprint Scripting

avatar image

219 11 20 31

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

i disagree with all of your points.

1) you claim they should both return -1 when they fail, but Array::Get does not return an index, it returns the element of the array, which can be of any type, and is usually not a number.

2) you claim they should throw a warning to the log, but failing to find an item in an array does not mean anything is wrong with the code. i don't want a log warning me every time my player tries to open a door, but the door does not find the door key in the player's inventory.

3) the return values for a template function cannot be documented, because they can be any class. you can expect that it returns either the default value for that type or that it returns null.

more ▼

answered Feb 18 '16 at 07:12 PM

avatar image

9.6k 319 205 449

avatar image 00k_ Feb 18 '16 at 09:19 PM

1) I agree. I was only looking at it from the perspective of INT arrays. Good point.

2) I can see this side of the argument. But I would like to have the option to know if my GET failed because it tried to access a part of the array that doesn't exist without having to build a test for it every time. For FIND I guess it's reasonable to simply check ISVALID after the get. Perhaps an improvement would be a success, BOOL output on GET and FIND nodes? (perhaps only on INT arrays since this is the only case where the result is ambiguous)

3) Actually the FIND in array does always return an INT which is the index to that objects position in the array. So I disagree with you on this point. You can document this. For GET I think you could also document that it will return NULL if it fails. Obvious for real programmers but not for beginners and such.

avatar image ScottSpadea Feb 18 '16 at 10:57 PM

i agree, the Find documentation should mention the -1 result, and the Get documentation should mention returning the default value of out of bounds indices.

the bool output on Get nodes could probably help a bit, but until something like that exists, you should usually compare the length of the array to the index you are trying to access, before you access it.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question