RealDocs

UKismetMathLibrary::SelectString

function Engine Blueprint Since 4.0
#include "Kismet/KismetMathLibrary.h"
Access: public Specifiers: staticBlueprintPureUFUNCTION

Description

Returns A if bPickA is true, otherwise returns B. A Blueprint-friendly conditional select that avoids a branch node when the choice between two constant strings is driven by a single boolean.

Caveats & Gotchas

  • Both A and B are fully evaluated before the selection is made — there is no short-circuit behaviour. If either string is produced by an expensive or side-effectful expression upstream in a Blueprint graph, both costs are always paid regardless of bPickA.
  • For choosing between more than two options, use a Map lookup or a Switch on String node instead of nested SelectString calls, which become unreadable and error-prone.

Signature

static UE_INL_API FString SelectString(const FString& A, const FString& B, bool bPickA);

Parameters

Name Type Description Default
A const FString& The value returned when bPickA is true.
B const FString& The value returned when bPickA is false.
bPickA bool Selects A when true, B when false.

Return Type

FString

Example

Choose a status label based on a boolean C++
bool bIsAlive = Character->IsAlive();
FString StatusLabel = UKismetMathLibrary::SelectString(TEXT("Alive"), TEXT("Dead"), bIsAlive);
HUD->SetStatusText(StatusLabel);

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.