Address of a lambda
Ali Çehreli via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Jul 7 11:12:46 PDT 2017
On 07/07/2017 10:52 AM, Ali Çehreli wrote:
> a solution with the addition of the
> keyword 'delegate':
As ag0aep6g explained, the 'delegate' keyword was not necessary there. A
case where it's needed is when defining a variable. The following code
compiles if 'delegate' keyword is present:
void foo(int delegate (int)) {
}
void main() {
// 'delegate' keyword needed to compile:
auto f = delegate (int i) => i * 2;
foo(f);
}
Ali
More information about the Digitalmars-d-learn
mailing list