RealDocs

UKismetArrayLibrary::Array_LastIndex

function Engine Blueprint Since unknown
#include "Kismet/KismetArrayLibrary.h"
Access: public Specifiers: staticBlueprintPureCustomThunk

Description

Returns the index of the last element in an array.

Caveats & Gotchas

  • Returns -1 for an empty array rather than 0, so don't assume the result is always a valid index — pair with Array_IsEmpty or Array_IsValidIndex first.
  • Equivalent to Array_Length(TargetArray) - 1, provided purely for readability in Blueprint graphs.
  • Marked BlueprintThreadSafe.

Signature

static int32 Array_LastIndex(const TArray<int32>& TargetArray);

Parameters

Name Type Description Default
TargetArray const TArray<int32>& The array to query.

Return Type

int32

Example

Get the last element via LastIndex + Get C++
TArray<int32> Values = { 10, 20, 30 };
const int32 LastIdx = UKismetArrayLibrary::Array_LastIndex(Values);
int32 LastItem;
UKismetArrayLibrary::Array_Get(Values, LastIdx, LastItem);
// LastItem == 30

Version History

Introduced in: unknown

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.