[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!
<<<<<<<<<<< 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.
For benefit of those who come across this:
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.
answered Feb 18 '16 at 07:12 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here