Skip to content

Commit 8c9e810

Browse files
committed
Docs: Clarify "named function expression" example
Closes #1234
1 parent aaa5b72 commit 8c9e810

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

docs/cpp2/expressions.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,12 +320,13 @@ main: () = {
320320

321321
Another example:
322322

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

0 commit comments

Comments
 (0)