-
Hello. I'm new to CPP2 but am hoping it will help me write cleaner and more expressive CPP code. My question is about the example in this page:
It is not clear to me how to read that
But this gives the error:
So what is all that about? Sorry for my ignorance… |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
|
Beta Was this translation helpful? Give feedback.
-
Variable defintion:
Function definition:
Lambdas:
Putting all that together:
e.g. you're defining a deduced variable |
Beta Was this translation helpful? Give feedback.
-
Thanks, great question! Yes, I want local functions (for my own use too) and to automate that rewrite, I just hadn't prioritized it yet. This is another prod for me to do that, thanks. In the meantime, I've just pushed a doc change to try to make that example clearer: I hope that will help. Thanks again. |
Beta Was this translation helpful? Give feedback.
func
is adeduced thing equal to
(:=
or: _ =
), then you are declaring an unnamed function by writing:() = { ... }
which is assigned tofunc
. The equivalent would be to just writefunc: () = { ... }
, but keep in mind that today it is not yet possible to write regular functions within another function body.