RealDocs

UKismetArrayLibrary::Array_Contains

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

Description

Returns true if the array contains at least one instance of a value.

Caveats & Gotchas

  • Implemented internally as Array_Find(...) >= 0, so it costs the same as a full linear search even though it only needs a boolean answer.
  • Displayed in Blueprint as 'Contains Item' with CompactNodeTitle 'CONTAINS'. Marked BlueprintThreadSafe.

Signature

static bool Array_Contains(const TArray<int32>& TargetArray, const int32& ItemToFind);

Parameters

Name Type Description Default
TargetArray const TArray<int32>& The array to search.
ItemToFind const int32& The value to search for.

Return Type

bool

Example

Check membership before processing C++
TArray<int32> Values = { 10, 20, 30 };
if (UKismetArrayLibrary::Array_Contains(Values, 20))
{
    // 20 is present in Values
}

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.