UKismetArrayLibrary::Array_IsValidIndex
#include "Kismet/KismetArrayLibrary.h"
Access: public
Specifiers: staticBlueprintPureCustomThunk
Description
Returns true if the given index is within bounds for the array — greater than or equal to zero and less than its length.
Caveats & Gotchas
- • The standard defensive check to place before Array_Get, Array_Set, Array_Remove, or Array_Swap in a Blueprint graph, since those nodes log warnings and no-op rather than crashing on bad indices — but that silent failure can still hide bugs if left unchecked.
- • Displayed in Blueprint as 'Is Valid Index' with CompactNodeTitle 'IS VALID INDEX'. Marked BlueprintThreadSafe.
Signature
static bool Array_IsValidIndex(const TArray<int32>& TargetArray, int32 IndexToTest); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| TargetArray | const TArray<int32>& | The array to test against. | — |
| IndexToTest | int32 | The index to validate. | — |
Return Type
bool Example
Guard an indexed read C++
TArray<int32> Values = { 10, 20, 30 };
const int32 Index = 5;
if (UKismetArrayLibrary::Array_IsValidIndex(Values, Index))
{
int32 Item;
UKismetArrayLibrary::Array_Get(Values, Index, Item);
}
// Index 5 is out of range, so the branch is skipped See Also
Tags
Version History
Introduced in: unknown
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?