How do I turn this definition of an anonymous function, An anonymous function is a function that is assigned to a variable. Anonymous functions are also used when you want to perform a short and straight forward task, into an analogy?
closed as unclear what you're asking by gnat, Martijn Pieters, Giorgio, Bart van Ingen Schenau, MichaelT Apr 22 '14 at 15:37Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question. |
|||||||||||||||||
|
Anonymous functions are simply functions with no name. An anonymous function assigned to an variable is a function that is created at run time and only accessible via the variable it's assigned to (read: scope of the variable). Many times a function name is not important but are assigned to a local variable of another function object. Here an anonymous function assigned to an local variable:
In short anonymous functions assigned to local variables are basically the same as methods in other OOP languages. I think it's better to say nothing than statements about programming based on number of lines. Too many lines of code is not a problem, only a result that's most commonly caused by a bad structure and low efficiency. |
|||
|
What do you mean by analogy? Being a C++/C# programmer primarily, I would have to say that that definition sounds very familiar to a C++/C# delegates and lamda expressions, or maybe function pointers. The link below explains the concept in C++. http://stackoverflow.com/questions/9568150/what-is-a-c-delegate It sounds like the variable would hold an address to a function along with parameter types specified in a certain order to call on those functions. Anonymous functions are to Javascript as delegates/lamda expressions/function pointers are to C#/C++? |
|||||||||||||||||||||
|