Skip to content

Commit

Permalink
Docs: Clarify "named function expression" example
Browse files Browse the repository at this point in the history
Closes #1234
  • Loading branch information
hsutter committed Aug 18, 2024
1 parent aaa5b72 commit 8c9e810
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions docs/cpp2/expressions.md
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,13 @@ main: () = {

Another example:

``` cpp title="Capture in a named function expression (aka lambda)" hl_lines="2 4 7 12 13"
``` cpp title="Capture in a named function expression (aka lambda)" hl_lines="2 4 9 14 15"
main: () = {
price := 100;
func := :() = {
std::cout << "Price = " << price$ << "\n";
};
func := // Note: 'func' is a named variable of deduced type initialized to ...
:() = { std::cout << "Price = " << price$ << "\n"; } // ... this lambda
; // This is a way to declare 'local functions', which can also capture
// (In the future, Cpp2 may directly support local functions)
func();
price = 200;
func();
Expand Down

0 comments on commit 8c9e810

Please sign in to comment.