Return statement: Difference between revisions
From Unreal Wiki, The Unreal Engine Documentation Site
New page: The '''return''' statement immediately exits the current function or operator. No statement logically following a '''return''' will be executed anymore. In state code, the '''... |
m formatting fix |
||
Line 1: | Line 1: | ||
The '''return''' statement immediately exits the current [[function]] or [[operator]]. No statement logically following a '''return''' will be executed anymore. | The '''return''' statement immediately exits the current [[function]] or [[operator]]. No statement logically following a '''return''' will be executed anymore. | ||
In [[state]] code, the '''return''' statement is not allowed. You can use the [[stop statement]] or call <code>GotoState('');</code> instead, depending on the desired effect. | In [[state]] code, the '''return''' statement is not allowed. You can use the [[stop statement]] or call <code>GotoState('<i></i>');</code> instead, depending on the desired effect. | ||
==Syntax== | ==Syntax== |
Latest revision as of 03:13, 5 March 2011
The return statement immediately exits the current function or operator. No statement logically following a return will be executed anymore.
In state code, the return statement is not allowed. You can use the stop statement or call GotoState('');
instead, depending on the desired effect.
Syntax
For function without a return type, the syntax simply is:
return;
However, if the function declaration contains a return type, the following variation must be used instead:
return expression;
The expression's type must be compatible to the function's return type.
Declarations | Preprocessor • Classes • Interfaces • Cpptext • Constants • Enums • Structs • Variables (Metadata) • Replication block • Operators • Delegates • Functions • States • Defaultproperties (Subobjects) |
---|---|
Types | bool • byte • float • int • name • string • Object • Class • Enums • Structs (Vector ⋅ Rotator ⋅ Quat ⋅ Color) • Static arrays • Dynamic arrays • Delegates • Typecasting |
Literals | Boolean • Float • Integer • Names • Objects (None ⋅ Self) • Vectors • Rotators • Strings |
Flow | GoTo • If • Assert • Return • Stop • Switch • While • Do...Until • For • ForEach • Break • Continue |
Specifiers | Super • Global • Static • Default • Const |
UnrealScript | Syntax • .UC • .UCI • .UPKG • Comments • #directives • Native |