http://www.evilbore.com/forum/index.php?topic=30542.msg958245#msg958245I posted this a month ago and didn't think more about it until last night.
Anyway, it was basically asking, "wha?" at this snippet of code:
Func<int, Func<int, int>> MakeAdder = x => y => x + y;
Func<int, int> Adder = MakeAdder(10);
Console.WriteLine(Adder(20));
Being new at lambda expressions at the time, I had no idea how this whole thing worked. I couldn't comprehend the syntax. I knew the result because obviously (a) I could test it and (b) I could mentally put together 10 and 20 just like anybody else. But
how it was getting there, I couldn't explain. Until now, of course. And now it seems all so simple.
Anyway, MakeAdder is a function that accepts an integer parameter and spits out another function. It's a function in my function, as Xzibit-meme-guy would say. Basically, you give it "x", and the function returns a function that takes an integer value (y) and adds it to the previously supplied "x."
So by setting Adder = MakeAdder(10), what I've done is retrieved a function that is equal to y => 10 + y. Then by using Adder and supplying an argument of 20, the whole thing evaluates to 30. Simple.
This is important stuff, which is why I've posted an update. Someday in the future, perhaps even on your deathbeds, you will thank me for this.