Skip to content

Commit 7a5601e

Browse files
committed
Add argument to lambda example
1 parent 99964d6 commit 7a5601e

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

docs/systems/async.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ auto BoundLambda = Bind(
169169
* the first argument and the lambda will be bound to the global lifetime.
170170
*/
171171
this,
172-
[this](IUnbound) -> TTask<void, ETaskBinding::Unbound>
172+
[this](IUnbound, FString Message) -> TTask<void, ETaskBinding::Unbound>
173173
{
174174
// 'this' captured can be safely accessed; the lambda will not continue beyond a co_await
175175
// if the bound lifetime is no longer valid.
@@ -178,13 +178,13 @@ auto BoundLambda = Bind(
178178
co_await Delay(Seconds);
179179

180180
// Print out a message.
181-
UE_LOG(LogTemp, Warning, TEXT("Waiting %f seconds."), Seconds);
181+
UE_LOG(LogTemp, Warning, TEXT("Waiting %f seconds, message was %s."), Seconds, *Message);
182182

183183
// co_return - always required, even in TTask<void> functions.
184184
co_return;
185185
});
186186

187-
co_await BoundLambda();
187+
co_await BoundLambda(TEXT("My message!"));
188188
```
189189
190190
When using `ETaskBinding::Unbound`, the first argument must always be the `IUnbound` type. You can't construct the `IUnbound` type and must use `Bind()` to return the version of the lambda that does not require `IUnbound` to be passed in. This is to ensure that lambdas using `ETaskBinding::Unbound` can't be accidentally used without using `Bind()`.

0 commit comments

Comments
 (0)