Posts Tagged anonymous function

C++ Scripting: Part 15 – Delegates

Tags: , , , ,

This week’s article adds another major feature to the C++ scripting system: delegates. These are vital so C++ game code can use features like Unity’s UI system (a.k.a. UGUI). Without them, we wouldn’t be able to handle button clicks or other UI events. So read on to learn how these were implemented in the GitHub project.

Read the rest of this article »

No Comments

How Closures Work

Tags: , , ,

C#’s support for closures includes lambdas ((a, b) => a+b) and delegates (delegate(int a, int b){return a+b;}). They’re extremely handy tools that many developers use on a daily basis. For example, it’s really convenient when using List.Find to pass in a lambda like item => item.Id == IdToFind. They also make great callbacks for asynchronous operations. However you’re using them, understanding how they work behind the scenes will help you understand how they behave and give you insight when optimizing your code. Today’s article delves into the topic to gain just this understanding, so read on to learn some more about closures!

Read the rest of this article »

No Comments

From AS3 to C#, Part 16: Lambdas and Delegates

Tags: , , ,

Two of C#’s really interesting features are technically operators, but didn’t fit in last week’s article. These are both ways to create anonymous functions: lambdas and delegates. AS3 has anonymous functions too, but today’s article will discuss how they differ from the C# approaches. Read on to learn how to harness the power of anonymous functions in C#.

Read the rest of this article »

1 Comment