Slacker News Slacker News logo featuring a lazy sloth with a folded newspaper hat
  • top
  • new
  • show
  • ask
  • jobs
Library

Comment by WalterBright

6 hours ago

Lambdas in D are just nested functions:

    int foo(int i) {
        int add(int x) { return i + x; } // nested function
        return add(3);
    }

    int bar(int i {
        alias lambda = (x) => x + i;  // lambda
        return lambda(3);
    }
    }

0 comments

WalterBright

Reply

No comments yet

Contribute on Hacker News ↗

Slacker News

Product

  • API Reference
  • Hacker News RSS
  • Source on GitHub

Community

  • Support Ukraine
  • Equal Justice Initiative
  • GiveWell Charities